Skip to content

Commit

Permalink
parse: correctly handle fread() errors
Browse files Browse the repository at this point in the history
If no CCID reader is found then the size of the output.txt file is 0
bytes and fread(3) returns 0 but that is not an error.
  • Loading branch information
Ludovic Rousseau authored and LudovicRousseau committed Sep 7, 2023
1 parent ff9a39b commit 789bccd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ int main(int argc, char *argv[])
char buff[256];

s = fread(buff, 1, sizeof buff, fd);
if (0 == s)
if (0 == s && ferror(fd))
{
perror("fread");
perror("fread " OUTPUT_FILENAME);
return -1;
}
fwrite(buff, s, 1, stdout);
Expand Down

0 comments on commit 789bccd

Please sign in to comment.