1
0
mirror of https://github.com/cclassic/model-ghdl synced 2024-11-21 08:25: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){
ptr = buf - 1;
do { // TODO: Overflow protection!
do {
ptr++;
*ptr = fgetc(proc);
} while (*ptr != '\0' && *ptr != '\n' && *ptr != -1);
} while (*ptr != '\0' && *ptr != '\n' && *ptr != -1 && ptr < buf + sizeof(buf));
if (*ptr == -1)
break;
*ptr = '\0';