After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 554243 - select code in nanohttp module can cause problems in apps with more than 1024 open file descriptors
select code in nanohttp module can cause problems in apps with more than 1024...
Status: RESOLVED DUPLICATE of bug 559501
Product: libxml2
Classification: Platform
Component: general
git master
Other All
: Normal major
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2008-09-29 01:55 UTC by Eric Bowden
Modified: 2009-08-24 12:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
nanohttp-select-bug.c (857 bytes, text/plain)
2008-09-29 01:57 UTC, Eric Bowden
Details

Description Eric Bowden 2008-09-29 01:55:00 UTC
The select() code in the nanohttp and nanoftp modules uses statically sized fd_set's, which default to being large enough to hold 1024 file descriptor bits on most Unix systems.

This means that in applications with more than 1024 file descriptors open, using nanohttp or nanoftp will cause the FD_SET macro to write a bit somewhere off the end of the actual fd_set; currently there is no error-checking in place to prevent this.

fd_set's can be dynamically allocated instead to fix this, or poll() with a dynamically allocated number of pollfd structs could be used in addition to select() if it's supported.

To reproduce, set your ulimit -n to something fairly high (say, 100000 - running as root is the easiest way to do this) and compile & run the attached sample code.  It'll probably segfault; setting the number of file descriptors it opens to something a little lower will cause other errors, too, visible in Valgrind.
Comment 1 Eric Bowden 2008-09-29 01:57:34 UTC
Created attachment 119558 [details]
nanohttp-select-bug.c

Demonstrates the select bug with the nanohttp module.  A similar bug, reproducible with similar code,  exists in nanoftp as well.
Comment 2 Eric Bowden 2008-09-29 02:01:41 UTC
(I could fix this if wanted; it's not a very complicated fix.  Interestingly enough, it probably wouldn't be a problem on Windows, of all platforms, as the FD_* macros in Windows are a little smarter - so it might involve adding some ifdef's for _WIN32.  Let me know.)
Comment 3 Daniel Veillard 2009-08-24 12:19:08 UTC
Looks like a duplicate of 559501

*** This bug has been marked as a duplicate of bug 559501 ***