Description of problem:
the function fileno crash the program, if called with NULL parameter
according to the documentation it should return -1 and set errno
Version-Release number of selected component (if applicable):
Steps to Reproduce:
compille and run:
printf ("%d\n", fileno (NULL));
NULL is not a pointer to a stream.
NULL is the valid return value of fopen &tc.. so NULL can be considered as pointer to unopened stream.
from fileno man page:
These functions should not fail and do not set the external variable errno. (However, in case fileno() detects that its argument is not a valid stream, it must return -1 and set
errno to EBADF.)
Note that EBADF in this case is a MAY FAIL rather than MUST FAIL, so while fileno could return -1/EBADF in that case, it doesn't have to. And slowing the function down to cope with broken callers isn't a good idea.
That is irrelevant since NULL is not a pointer to a stream.