Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
secilc.c: Don't fail if input file is empty
fread(3) returns zero if |size| is zero. This confuses secilc, and
causes it to fail with a "Failure reading file" error, even though there
is no error.

Add a shortcut that closes and skips an input file if file size is zero.

Signed-off-by: Yi-Yo Chiang <yochiang@google.com>
  • Loading branch information
silverneko authored and jwcart2 committed Apr 14, 2021
1 parent 1e4e7f6 commit d1a34d3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions secilc/secilc.c
Expand Up @@ -268,6 +268,12 @@ int main(int argc, char *argv[])
}
file_size = filedata.st_size;

if (!file_size) {
fclose(file);
file = NULL;
continue;
}

buffer = malloc(file_size);
rc = fread(buffer, file_size, 1, file);
if (rc != 1) {
Expand Down

0 comments on commit d1a34d3

Please sign in to comment.