As mentioned in pr bin/22965, I stumbled across a bug
in libc/gen/getcap.c when compiling it under other
platforms.  The basic problem is some code which does:

         (void)fclose(pfp);
         if (ferror(pfp)) {
                 ...do stuff...
         }

I find it surprising that the above works under FreeBSD.
(not only that, it seems to work OK under several other
OS's too).  The fclose is supposed to throw away the
stream, but the ferror (apparently) still works with
that pointer.

The PR includes a patch for getcap.c (which is just to
use the result from fclose to determine if an error
occurred), but I also wonder if we should do something
so that this combination would ALWAYS fail.  It seems
to me that fclose should clear out whatever fields that
ferror is using for sanity-checking, and ferror should
always return an errno of 'bad parameter', or something
like that.

Or is there some reason that we DO want ferror to work
on streams which have already been closed?
-- 

---
Garance Alistair Drosehn            =   [EMAIL PROTECTED]
Senior Systems Programmer           or  [EMAIL PROTECTED]
Rensselaer Polytechnic Institute    or  [EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to