[vcom] Buffer overflow protection

This commit is contained in:
Markus Koch 2016-05-21 22:05:28 +02:00
parent 1df04509a4
commit f304d611a8
1 changed files with 2 additions and 3 deletions

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';