summaryrefslogtreecommitdiffstats
path: root/ChangeLog-2009-2015
diff options
context:
space:
mode:
authorPaul A. Patience <paul@apatience.com>2021-09-05 02:13:34 -0400
committerKaz Kylheku <kaz@kylheku.com>2021-09-06 10:28:45 -0700
commit9df5cdfd09145441f1f927e6deff5a999178bc53 (patch)
treebbe80190e673a0b3b2757bad28110618bd9c7197 /ChangeLog-2009-2015
parenta534a2bd5ca3e11ea26df4e285f3fcd88221fbe7 (diff)
downloadtxr-9df5cdfd09145441f1f927e6deff5a999178bc53.tar.gz
txr-9df5cdfd09145441f1f927e6deff5a999178bc53.tar.bz2
txr-9df5cdfd09145441f1f927e6deff5a999178bc53.zip
sockets: clear non-type bits after fd creation.
The SOCK_NONBLOCK and SOCK_CLOEXEC non-type bits are a convenience allowed by the socket and socketpair functions, but they prevent simple comparisons with the actual socket types SOCK_STREAM, SOCK_DGRAM, etc. Before this commit, opening datagram sockets with any of these bits ORed into the type would result in TXR not realizing that such sockets were datagram sockets because the type would be compared directly with SOCK_DGRAM. Various problems would ensue, such as calling listen on a datagram socket. This commit clears the SOCK_NONBLOCK and SOCK_CLOEXEC bits after calling socket or socketpair so that the socket streams get the actual socket type. A potentially better solution would be to manually define SOCK_TYPE_MASK as 0xF (because although Linux defines it as such in include/linux/net.h, it doesn't export it to userspace) and AND it with the socket type, because clearing SOCK_NONBLOCK and SOCK_CLOEXEC will not be enough if new flags are added in the future, and it's probably more likely for that to happen than for SOCK_TYPE_MASK to be changed. * socket.c (open_socket, socketpair_wrap): Clear the SOCK_NONBLOCK and SOCK_CLOEXEC bits from the socket type after calling socket or socketpair, and before initializing the socket streams.
Diffstat (limited to 'ChangeLog-2009-2015')
0 files changed, 0 insertions, 0 deletions