]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Return -1 instead of EOF and set errno if the stream is not a real file stream.
authorUlrich Drepper <drepper@redhat.com>
Thu, 8 Jul 1999 11:55:34 +0000 (11:55 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 8 Jul 1999 11:55:34 +0000 (11:55 +0000)
libio/fileno.c

index 7ff93e6a8138839d825718280f4407b639e88ab6..92334f156429868a44664de746e2e6612085aec4 100644 (file)
@@ -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);
 }