From 9bc3ffe6ec2bec8a7fcddeeda273337035e6b956 Mon Sep 17 00:00:00 2001 From: carl Date: Sun, 31 Mar 2019 00:52:27 +0800 Subject: [PATCH] Buffer overflow memory errors. --- fast/driver/driver.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fast/driver/driver.c b/fast/driver/driver.c index f78a1d002..48aed8cc9 100644 --- a/fast/driver/driver.c +++ b/fast/driver/driver.c @@ -476,9 +476,13 @@ int main(int argc, char *argv[]) append(&SRCFILES, str); break; case 'M': /* use other compiler (for testing) */ + free(COMP); + COMP = alloc(strlen(str)+2-1); strcpy(COMP, str + 2); break; case 'P': /* use other cpp (for testing) */ + free(CPP); + CPP = alloc(strlen(str)+2-1); strcpy(CPP, str + 2); break; case 's': /* strip */ @@ -742,6 +746,7 @@ static char * expand_string(char *s) if (!expanded) return s; *q++ = '\0'; + /* Do not forget the missing null character. */ p = alloc((unsigned int) (q - buf)); return strcpy(p, buf); }