tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

short _file in stdio -> fd leak


So at work we ran into a situation where a process had to fdopen more
than 32K files, which lead to a file descriptor leak.  The reason for
this leak was that while regular fds are ints, _file is a short, so if
fdopen got an fd larger than SHRT_MAX, it would get sign-extended and
thus become invalid, causing the subsequent fclose to fail.

This being FreeBSD, the fix was found and contributed back into
FreeBSD's repository by John Baldwin in;r2=1.9
(with surrounding discussion on

I believe that we are affected by the same problem and would like to
commit the same (simple short-term) fix.  Any objections?


"When it's fall in New York, the air smells as if someone's been frying
goats in it, and if you are keen to breathe the best plan is to open a
window and stick your head in a building."

Attachment: pgpHf3LUraAH0.pgp
Description: PGP signature

Home | Main Index | Thread Index | Old Index