From: Denys Vlasenko Date: Wed, 24 Dec 2014 00:46:29 +0000 (+0100) Subject: libbb: add sanity check in bb_arg_max() X-Git-Tag: 1_23_0~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ca9c4653a95907e32674c2eb5dc3921dc8e6f1a0;p=oweals%2Fbusybox.git libbb: add sanity check in bb_arg_max() Signed-off-by: Denys Vlasenko --- diff --git a/libbb/sysconf.c b/libbb/sysconf.c index cfad9cdc0..8c1caef5c 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