Skip to content

Commit db468f1

Browse files
authored
close pipe before failure check, limit scanf length (#78)
1 parent 676673e commit db468f1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/fetch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ char *pipeRead(const char *exec)
5454
if (pipe == NULL)
5555
return NULL;
5656
char *returnVal = malloc(256);
57-
const int scanf_return = fscanf(pipe, "%[^\n]s", returnVal);
57+
const int scanf_return = fscanf(pipe, "%[^\n]256s", returnVal);
58+
pclose(pipe);
5859
if (scanf_return == EOF) {
5960
fprintf(stderr, "ERROR: scanf failed!\n");
6061
exit(EXIT_FAILURE);
6162
}
62-
pclose(pipe);
6363
return returnVal;
6464
}
6565

0 commit comments

Comments
 (0)