mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-19 09:15:34 -04:00
Avoid leaking fd in evutil_socket() by Linux.
Found by Amarin Phaosawasdi
This commit is contained in:
parent
a3cec90961
commit
a6492cb744
4
evutil.c
4
evutil.c
@ -2389,7 +2389,9 @@ evutil_socket(int domain, int type, int protocol)
|
||||
evutil_socket_t r;
|
||||
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)
|
||||
r = socket(domain, type, protocol);
|
||||
if (r < 0 && !(type & (SOCK_NONBLOCK|SOCK_CLOEXEC)))
|
||||
if (r >= 0)
|
||||
return r;
|
||||
else if ((type & (SOCK_NONBLOCK|SOCK_CLOEXEC)) == 0)
|
||||
return -1;
|
||||
#endif
|
||||
#define SOCKET_TYPE_MASK (~(EVUTIL_SOCK_NONBLOCK|EVUTIL_SOCK_CLOEXEC))
|
||||
|
Loading…
x
Reference in New Issue
Block a user