1
0
mirror of https://github.com/cclassic/model-ghdl synced 2024-11-22 08:35:05 +01:00

[vcom] Buffer overflow protection

This commit is contained in:
Markus Koch 2016-05-21 22:05:28 +02:00
parent 1df04509a4
commit f304d611a8

5
main.c
View File

@ -105,11 +105,10 @@ int run_ghdl(char *command, ...) {
while(42){ while(42){
ptr = buf - 1; ptr = buf - 1;
do {
do { // TODO: Overflow protection!
ptr++; ptr++;
*ptr = fgetc(proc); *ptr = fgetc(proc);
} while (*ptr != '\0' && *ptr != '\n' && *ptr != -1); } while (*ptr != '\0' && *ptr != '\n' && *ptr != -1 && ptr < buf + sizeof(buf));
if (*ptr == -1) if (*ptr == -1)
break; break;
*ptr = '\0'; *ptr = '\0';