summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2016-11-04 09:44:04 +0100
committerAndreas Schneider <asn@samba.org>2016-11-04 10:54:47 +0100
commit888a62e2c81370ab32e9bc790f12419148bd8972 (patch)
tree5d2531aed15455782adbd1701380c63e94db4e8e /src
parent057a956ad4cfe2bc6e03ec9033a8a9b15e8c88a1 (diff)
downloadsocket_wrapper-888a62e2c81370ab32e9bc790f12419148bd8972.tar.gz
socket_wrapper-888a62e2c81370ab32e9bc790f12419148bd8972.tar.xz
socket_wrapper-888a62e2c81370ab32e9bc790f12419148bd8972.zip
swrap: Add sanity check in socket_wrapper_max_sockets()
CID 153962 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index ece5a10..186b696 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -259,6 +259,8 @@ do { \
*/
#define SOCKET_WRAPPER_MAX_SOCKETS_DEFAULT 65535
+#define SOCKET_WRAPPER_MAX_SOCKETS_LIMIT 256000
+
/* This limit is to avoid broadcast sendto() needing to stat too many
* files. It may be raised (with a performance cost) to up to 254
* without changing the format above */
@@ -1141,6 +1143,11 @@ static size_t socket_wrapper_max_sockets(void)
if (s == endp) {
goto done;
}
+ if (tmp == 0 || tmp > SOCKET_WRAPPER_MAX_SOCKETS_LIMIT) {
+ SWRAP_LOG(SWRAP_LOG_ERROR,
+ "Invalid number of sockets specified, using default.");
+ goto done;
+ }
max_sockets = tmp;