libbb: add sanity check in bb_arg_max()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
11775edbfc
commit
ca9c4653a9
@ -11,7 +11,15 @@
|
|||||||
#if !defined(bb_arg_max)
|
#if !defined(bb_arg_max)
|
||||||
unsigned FAST_FUNC bb_arg_max(void)
|
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
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user