secilc.c: Don't fail if input file is empty
PATCH 1/1 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.
--- secilc/secilc.c | 6 ++++++ 1 file changed, 6 insertions(+)
secilc/secilc.c +6 -0
@@ -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 ) {
Signature · 1 line
2.31.1.295.g9ea45b61b8-goog
Quoted 8 lines · Yi-Yo Chiang
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 <[email protected]>
Quoted 24 lines
--- secilc/secilc.c | 6 ++++++ 1 file changed, 6 insertions(+)secilc/secilc.c +6
-1@@ -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 ) { --2.31.1.295.g9ea45b61b8-goog
James Carter
AppliedQuoted 7 lines · James Carter
Quoted 5 lines · Yi-Yo Chiang
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.
Quoted 6 lines
Quoted 3 lines
Add a shortcut that closes and skips an input file if file size is zero.
Signed-off-by Yi-Yo Chiang <[email protected]>Acked-by James Carter <[email protected]>
Applied.
Thanks,
Jim
Quoted 24 lines
Quoted 24 lines
--- secilc/secilc.c | 6 ++++++ 1 file changed, 6 insertions(+)secilc/secilc.c +6
-1@@ -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 ) { --2.31.1.295.g9ea45b61b8-goog