secilc/0003-secilc.c-Don-t-fail-if-input-file-is-empty.patch
Petr Lautrbach 36d6db55b0 Rebase on upstream commit 32611aea6543
See
    $ cd SELinuxProject/selinux
    $ git log --pretty=oneline secilc-3.2..32611aea6543 -- secilc
2021-07-29 07:30:43 +02:00

37 lines
962 B
Diff

From d1a34d3f1df5e90c9e01fcd9791c26db89064a7e Mon Sep 17 00:00:00 2001
From: Yi-Yo Chiang <yochiang@google.com>
Date: Wed, 14 Apr 2021 22:10:27 +0800
Subject: [PATCH] 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>
---
secilc/secilc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/secilc/secilc.c b/secilc/secilc.c
index 186c5a730221..9c78e42565e9 100644
--- a/secilc/secilc.c
+++ b/secilc/secilc.c
@@ -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.32.0