aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar nafets <fis.stefan@gmail.com> 2014-11-19 22:34:23 +0100
committerGravatar Sven Nierlein <sven@nierlein.de> 2014-11-28 15:21:23 +0100
commit6bb5e1db525f44a7ab40e9391244dbe65daa08cc (patch)
treeeb2f16e6694fb572b61e265a8ee8e8afa946cea9 /lib
parent054bfc992239e531ab6c9bb7e3a5d777f3c8a009 (diff)
downloadmonitoring-plugins-6bb5e1db525f44a7ab40e9391244dbe65daa08cc.tar.gz
avoid a segfault, if ulimit is set to unlimited
Diffstat (limited to 'lib')
-rw-r--r--lib/utils_cmd.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 9e214bd4..e41a9821 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -116,6 +116,14 @@ cmd_init (void)
}
#endif
+ /* if maxfd is unnaturally high, we force it to a lower value
+ * ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause
+ * a segfault when following calloc is called ... ) */
+
+ if ( maxfd > 2048 ) {
+ maxfd = 2048;
+ }
+
if (!_cmd_pids)
_cmd_pids = calloc (maxfd, sizeof (pid_t));
}