Skip to content

eBPF-based security platform

io: return the sealed opener's error as it is

Daniel Borkmann44b09a2d5f07
diff --git a/util/io.c b/util/io.c
index f1537264..07a14d6c 100644
--- a/util/io.c
+++ b/util/io.c
@@ -47,12 +47,15 @@ int read_file(const char *path, size_t max, void *out, size_t *len)
size_t left;
int fd, rc;
- if (under(path, SHIRUDO_VAR_LIB))
+ if (under(path, SHIRUDO_VAR_LIB)) {
fd = seal_open_read(path);
- else
+ if (fd < 0)
+ return fd;
+ } else {
fd = open(path, O_RDONLY | O_CLOEXEC);
- if (fd < 0)
- return fd == -1 ? -errno : fd;
+ if (fd < 0)
+ return -errno;
+ }
if (fstat(fd, &st) != 0) {
rc = -errno;
goto out;