summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authornafets <fis.stefan@gmail.com>2014-11-19 21:34:23 (GMT)
committerSven Nierlein <sven@nierlein.de>2014-11-28 14:21:23 (GMT)
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 9e214bd..e41a982 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -116,6 +116,14 @@ cmd_init (void)
116 } 116 }
117#endif 117#endif
118 118
119 /* if maxfd is unnaturally high, we force it to a lower value
120 * ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause
121 * a segfault when following calloc is called ... ) */
122
123 if ( maxfd > 2048 ) {
124 maxfd = 2048;
125 }
126
119 if (!_cmd_pids) 127 if (!_cmd_pids)
120 _cmd_pids = calloc (maxfd, sizeof (pid_t)); 128 _cmd_pids = calloc (maxfd, sizeof (pid_t));
121} 129}