FD_SET and FORTIFY_SOURCE
Florian Weimer
fweimer@redhat.com
Thu Feb 28 16:24:00 GMT 2013
On 02/28/2013 02:41 PM, Rich Felker wrote:
> The problem is that a large amount of otherwise-correct software uses
> malloc and out-of-bounds FD_SET arguments to work with sets larger
> than FD_SETSIZE. I have written on the issue before that the "correct"
> way to do this is allocate an array of fd_set objects and use / and %
> to address the bit rather than passing an out-of-bounds argument to
> FD_SET (which invokes UB), but some important software like libevent
> (if I remember correctly) remains wrong in this regard.
The order of bits is unspecified. The fd_set elements are typically
words, not bytes, and the bit order of the two access patterns differs
on big-endian machines. (I believe this has been used as an argument
that little-endian is the natural order, the Internet not withstanding.)
I can't believe that your kludge is actually more portable than just
requiring poll support. 8-)
(Writing a poll emulation on top of select isn't that hard, if you need it.)
--
Florian Weimer / Red Hat Product Security Team
More information about the Libc-alpha
mailing list