From: Ulrich Drepper Date: Thu, 8 Jul 1999 11:55:34 +0000 (+0000) Subject: Return -1 instead of EOF and set errno if the stream is not a real file stream. X-Git-Tag: cvs/glibc_2-1-2~316 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cb22d4a460cf9261f3e3f26750ce5f8520ba9680;p=thirdparty%2Fglibc.git Return -1 instead of EOF and set errno if the stream is not a real file stream. --- diff --git a/libio/fileno.c b/libio/fileno.c index 7ff93e6a813..92334f15642 100644 --- a/libio/fileno.c +++ b/libio/fileno.c @@ -32,8 +32,11 @@ fileno (fp) { CHECK_FILE (fp, EOF); - if (!(fp->_flags & _IO_IS_FILEBUF)) - return EOF; + if (!(fp->_flags & _IO_IS_FILEBUF) || _IO_fileno (fp) < 0) + { + __set_errno (EBADF); + return -1; + } return _IO_fileno (fp); }