summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko2014-12-24 01:46:29 +0100
committerDenys Vlasenko2014-12-24 01:46:29 +0100
commitca9c4653a95907e32674c2eb5dc3921dc8e6f1a0 (patch)
treeae34c51b8329a5cdb73d4a5f6c242d20b14e9e8c /libbb
parent11775edbfc27d2ad1cd0dff3f7af385f67719866 (diff)
downloadbusybox-ca9c4653a95907e32674c2eb5dc3921dc8e6f1a0.zip
busybox-ca9c4653a95907e32674c2eb5dc3921dc8e6f1a0.tar.gz
libbb: add sanity check in bb_arg_max()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/sysconf.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libbb/sysconf.c b/libbb/sysconf.c
index cfad9cd..8c1caef 100644
--- a/libbb/sysconf.c
+++ b/libbb/sysconf.c
@@ -11,7 +11,15 @@
#if !defined(bb_arg_max)
unsigned FAST_FUNC bb_arg_max(void)
{
- return sysconf(_SC_ARG_MAX);
+ long r = sysconf(_SC_ARG_MAX);
+
+ /* I've seen a version of uclibc which returned -1.
+ * Guard about it, and also avoid insanely large values
+ */
+ if ((unsigned long)r > 64*1024*1024)
+ r = 64*1024*1024;
+
+ return r;
}
#endif