aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornoneofyourbusiness <noneofyourbusiness@localhost>2022-09-26 12:07:43 +0200
committerMattias Andrée <maandree@kth.se>2023-07-02 11:47:35 +0200
commite6e58c96802d6611c9b4f25025a800dd4e0b75a3 (patch)
tree2c17692002ae312d8c3fc7a13809829b1cff67c3
parentAssume libc (correctly) does not define union semun (diff)
downloadbus-e6e58c96802d6611c9b4f25025a800dd4e0b75a3.tar.gz
bus-e6e58c96802d6611c9b4f25025a800dd4e0b75a3.tar.bz2
bus-e6e58c96802d6611c9b4f25025a800dd4e0b75a3.tar.xz
libbus.c: handle fopen() errors in bus_open
-rw-r--r--libbus.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libbus.c b/libbus.c
index 5abb4e5..b691940 100644
--- a/libbus.c
+++ b/libbus.c
@@ -670,6 +670,10 @@ bus_open(bus_t *restrict bus, const char *restrict file, int flags)
f = fopen(file, "r");
+ if (f == NULL) {
+ goto fail;
+ }
+
t(getline(&line, &len, f));
t(bus->key_sem = (key_t)atoll(line));
free(line), line = NULL, len = 0;
@@ -684,6 +688,7 @@ bus_open(bus_t *restrict bus, const char *restrict file, int flags)
t(open_semaphores(bus));
t(open_shared_memory(bus, flags));
}
+
return 0;
fail:
saved_errno = errno;