diff options
author | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2008-07-16 23:11:29 +0000 |
---|---|---|
committer | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2008-07-16 23:11:29 +0000 |
commit | e2e10f8d7a4d9477a8e35d10df5f54885fe3c092 (patch) | |
tree | 380ffb4dc6692ee377c0f4654e1982fd17f920b0 | |
parent | In the Windows version of tun_finalize, on errors that would (diff) | |
download | openvpn-e2e10f8d7a4d9477a8e35d10df5f54885fe3c092.tar.xz |
Added SOCKET_SND_RCV_BUF_MAX constant (set to 1000000) to limit the
maximum size passed to setsockopt SNDBUF/RCVBUF.
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3062 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to '')
-rw-r--r-- | socket.c | 16 | ||||
-rw-r--r-- | socket.h | 5 |
2 files changed, 16 insertions, 5 deletions
@@ -292,9 +292,12 @@ static void socket_set_sndbuf (int sd, int size) { #if defined(HAVE_SETSOCKOPT) && defined(SOL_SOCKET) && defined(SO_SNDBUF) - if (setsockopt (sd, SOL_SOCKET, SO_SNDBUF, (void *) &size, sizeof (size)) != 0) + if (size > 0 && size < SOCKET_SND_RCV_BUF_MAX) { - msg (M_WARN, "NOTE: setsockopt SO_SNDBUF=%d failed", size); + if (setsockopt (sd, SOL_SOCKET, SO_SNDBUF, (void *) &size, sizeof (size)) != 0) + { + msg (M_WARN, "NOTE: setsockopt SO_SNDBUF=%d failed", size); + } } #endif } @@ -318,10 +321,13 @@ static bool socket_set_rcvbuf (int sd, int size) { #if defined(HAVE_SETSOCKOPT) && defined(SOL_SOCKET) && defined(SO_RCVBUF) - if (setsockopt (sd, SOL_SOCKET, SO_RCVBUF, (void *) &size, sizeof (size)) != 0) + if (size > 0 && size < SOCKET_SND_RCV_BUF_MAX) { - msg (M_WARN, "NOTE: setsockopt SO_RCVBUF=%d failed", size); - return false; + if (setsockopt (sd, SOL_SOCKET, SO_RCVBUF, (void *) &size, sizeof (size)) != 0) + { + msg (M_WARN, "NOTE: setsockopt SO_RCVBUF=%d failed", size); + return false; + } } return true; #endif @@ -42,6 +42,11 @@ #define OPENVPN_PORT 1194 /* + * Maximum size passed passed to setsockopt SNDBUF/RCVBUF + */ +#define SOCKET_SND_RCV_BUF_MAX 1000000 + +/* * Number of seconds that "resolv-retry infinite" * represents. */ |