mirror of
https://review.haiku-os.org/buildtools
synced 2024-11-23 07:18:49 +01:00
Increase MAXSYM and add sanity checks.
I had jam crash in strange ways because a stack-allocatted aray was overflowing. Double the limit, and add sanity checks with exit and clear error messages in case it happens again.
This commit is contained in:
parent
560f4f562f
commit
259af3cf06
@ -305,6 +305,10 @@ builtin_match(
|
||||
{
|
||||
char buf[ MAXSYM ];
|
||||
int l = re->endp[i] - re->startp[i];
|
||||
if (l > MAXSYM) {
|
||||
printf("MAXSYM is too low! NEed at least %d\n", l);
|
||||
exit(-1);
|
||||
}
|
||||
memcpy( buf, re->startp[i], l );
|
||||
buf[ l ] = 0;
|
||||
result = list_new( result, buf, 0 );
|
||||
|
@ -206,6 +206,10 @@ var_expand(
|
||||
/* Look for a : modifier in the variable name */
|
||||
/* Must copy into varname so we can modify it */
|
||||
|
||||
if (strlen(vars->string) > MAXSYM) {
|
||||
printf("MAXSYM is too low! Need at least %d\n", l);
|
||||
exit(-1);
|
||||
}
|
||||
strcpy( varname, vars->string );
|
||||
|
||||
if( colon = strchr( varname, MAGIC_COLON ) )
|
||||
@ -274,6 +278,10 @@ var_expand(
|
||||
LIST *rem;
|
||||
char *out1;
|
||||
|
||||
if (out - out_buf > MAXSYM) {
|
||||
printf("MAXSYM is too low!\n");
|
||||
exit(-1);
|
||||
}
|
||||
/* Handle end subscript (length actually) */
|
||||
|
||||
if( sub2 >= 0 && --sub2 < 0 )
|
||||
|
@ -129,6 +129,10 @@ headers1(
|
||||
|
||||
char buf2[ MAXSYM ];
|
||||
int l = re[i]->endp[1] - re[i]->startp[1];
|
||||
if (l > MAXSYM) {
|
||||
printf("MAXSYM is too low! Need at least %d\n", l);
|
||||
exit(-1);
|
||||
}
|
||||
memcpy( buf2, re[i]->startp[1], l );
|
||||
buf2[ l ] = 0;
|
||||
result = list_new( result, buf2, 0 );
|
||||
|
@ -478,7 +478,7 @@
|
||||
|
||||
/* You probably don't need to muck with these. */
|
||||
|
||||
# define MAXSYM 1024 /* longest symbol in the environment */
|
||||
# define MAXSYM 2048 /* longest symbol in the environment */
|
||||
# define MAXJPATH 1024 /* longest filename */
|
||||
|
||||
# define MAXJOBS 64 /* silently enforce -j limit */
|
||||
|
@ -117,6 +117,10 @@ var_defines( const char **e )
|
||||
|
||||
/* Get name */
|
||||
|
||||
if (val - *e > MAXSYM) {
|
||||
printf("MAXSYM is too low, need at least %d\n", val - *e);
|
||||
exit(-1);
|
||||
}
|
||||
strncpy( buf, *e, val - *e );
|
||||
buf[ val - *e ] = '\0';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user