diff options
author | Joseph Henry <joseph.henry@zerotier.com> | 2015-10-13 17:05:11 -0400 |
---|---|---|
committer | Joseph Henry <joseph.henry@zerotier.com> | 2015-10-13 17:05:11 -0400 |
commit | 0912d4be59165f2a5b70b296c947fd76d9b7c3a0 (patch) | |
tree | fd5ebe301d0e08377b590c08f48e7b43a5b4ed47 /netcon/intercept.c | |
parent | 73145de618e29032816eb753be8763b6710ea30b (diff) | |
download | infinitytier-0912d4be59165f2a5b70b296c947fd76d9b7c3a0.tar.gz infinitytier-0912d4be59165f2a5b70b296c947fd76d9b7c3a0.zip |
Fixed socket protocol check logic in socket()
Diffstat (limited to 'netcon/intercept.c')
-rwxr-xr-x | netcon/intercept.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/netcon/intercept.c b/netcon/intercept.c index 41ad804c..a2d6e31a 100755 --- a/netcon/intercept.c +++ b/netcon/intercept.c @@ -515,15 +515,16 @@ void sock_domain_to_str(int domain) int socket(SOCKET_SIG) { #ifdef CHECKS + /* Check that type makes sense */ + int flags = socket_type & ~SOCK_TYPE_MASK; + if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) + return -EINVAL; + socket_type &= SOCK_TYPE_MASK; /* Check protocol is in range */ if (socket_family < 0 || socket_family >= NPROTO) return -EAFNOSUPPORT; if (socket_type < 0 || socket_type >= SOCK_MAX) return -EINVAL; - /* Check that type makes sense */ - int flags = socket_type & ~SOCK_TYPE_MASK; - if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) - return -EINVAL; #endif #ifdef DUMMY @@ -658,7 +659,8 @@ int connect(CONNECT_SIG) ---------------------------------- select() ------------------------------------ ------------------------------------------------------------------------------*/ -/* int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout */ +/* int n, fd_set *readfds, fd_set *writefds, +fd_set *exceptfds, struct timeval *timeout */ int select(SELECT_SIG) { #ifdef DUMMY |