Buffer overflow memory errors.

This commit is contained in:
carl 2019-03-31 00:52:27 +08:00
parent 496795f0cf
commit 9bc3ffe6ec

View file

@ -476,9 +476,13 @@ int main(int argc, char *argv[])
append(&SRCFILES, str); append(&SRCFILES, str);
break; break;
case 'M': /* use other compiler (for testing) */ case 'M': /* use other compiler (for testing) */
free(COMP);
COMP = alloc(strlen(str)+2-1);
strcpy(COMP, str + 2); strcpy(COMP, str + 2);
break; break;
case 'P': /* use other cpp (for testing) */ case 'P': /* use other cpp (for testing) */
free(CPP);
CPP = alloc(strlen(str)+2-1);
strcpy(CPP, str + 2); strcpy(CPP, str + 2);
break; break;
case 's': /* strip */ case 's': /* strip */
@ -742,6 +746,7 @@ static char * expand_string(char *s)
if (!expanded) if (!expanded)
return s; return s;
*q++ = '\0'; *q++ = '\0';
/* Do not forget the missing null character. */
p = alloc((unsigned int) (q - buf)); p = alloc((unsigned int) (q - buf));
return strcpy(p, buf); return strcpy(p, buf);
} }