← Commit list

ca9c4653a

Denys Vlasenko
Denys Vlasenko
2014-12-24
SUCCESS Duration: 145s

Subject

libbb: add sanity check in bb_arg_max()

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

libbb/sysconf.c+9 -1
@@ -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