Serious bug in stdio on some ``System V'' derivatives
Rob Warnock
rpw3 at amdcad.AMD.COM
Wed Oct 5 13:46:19 AEST 1988
In article <591535074.12423 at minster.york.ac.uk> bin at minster.york.ac.uk writes:
+---------------
| Berkeley networking has nothing to do with this, of course, except
| that ``System V'' systems that have sockets (and perhaps NFS) seem
| to be more likely to increase NOFILE...
| Berkeley systems, including Suns, are unaffected, since they sensibly
| put the extra value in the FILE structure.
+---------------
Well, having just done a port of the Berkeley networking code into a System-V,
let me point out that whoever ported your stuff had to fix a related problem
I ran into over and over, a problem due to the *#&^$*#& "_bufendtab[]" which
(as you say) does not exist in Berkeley systems:
If you do an "freopen" of a file descriptor which is already open in
an stdio stream, since the "_bufendtab[]" is indexed by *file descriptor*
your new FILE will stuff *its* bufend over the *old* FILE's. This will
cause illegal memory references and other assorted mayhem if you ever
use the old FILE for anything! (*Hack* solution: change all cases of such
"freopen(s,...) to "freopen(dup(s),...)", so as to get a new bufend entry.)
Having _bufend be in a table indexed by f.d. instead of FILE* was a ghastly
mistake. I certainly hope more recent versions of System-V have fixed it.
Rob Warnock
Systems Architecture Consultant
UUCP: {amdcad,fortune,sun}!redwood!rpw3
ATTmail: !rpw3
DDD: (415)572-2607
USPS: 627 26th Ave, San Mateo, CA 94403
More information about the Comp.bugs.sys5
mailing list