diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2023-09-21 06:31:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-21 06:31:58 -0400 |
| commit | cd3bd19314ac86c25a7831f995947fae67c6706d (patch) | |
| tree | c5b67cd6b3b62a8bea736777a026024b3805e561 /lib/zlog_5424.c | |
| parent | d81e492368b8b78ab1f4fbaba3e72d93c3958608 (diff) | |
| parent | 448d690a354c3ea481aba6254a285937d843cf81 (diff) | |
Merge pull request #14454 from opensourcerouting/coverity-20230920
lib: fix a bunch of coverity nits
Diffstat (limited to 'lib/zlog_5424.c')
| -rw-r--r-- | lib/zlog_5424.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/zlog_5424.c b/lib/zlog_5424.c index c15bdece29..9bc1c819a8 100644 --- a/lib/zlog_5424.c +++ b/lib/zlog_5424.c @@ -877,10 +877,15 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type) switch (zcf->dst) { case ZLOG_5424_DST_NONE: - break; + return -1; case ZLOG_5424_DST_FD: fd = dup(zcf->fd); + if (fd < 0) { + flog_err_sys(EC_LIB_SYSTEM_CALL, + "failed to dup() log file descriptor: %m (FD limit too low?)"); + return -1; + } optlen = sizeof(sock_type); if (!getsockopt(fd, SOL_SOCKET, SO_TYPE, &sock_type, &optlen)) { @@ -891,7 +896,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type) case ZLOG_5424_DST_FIFO: if (!zcf->filename) - break; + return -1; if (!zcf->file_nocreate) { frr_with_privs (lib_privs) { @@ -904,7 +909,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type) if (err == 0) do_chown = true; else if (errno != EEXIST) - break; + return -1; } flags = O_NONBLOCK; @@ -912,7 +917,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type) case ZLOG_5424_DST_FILE: if (!zcf->filename) - break; + return -1; frr_with_privs (lib_privs) { fd = open(zcf->filename, flags | O_WRONLY | O_APPEND | @@ -924,7 +929,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type) flog_err_sys(EC_LIB_SYSTEM_CALL, "could not open log file %pSE: %m", zcf->filename); - break; + return -1; } frr_with_privs (lib_privs) { @@ -952,11 +957,11 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type) flog_err_sys(EC_LIB_SYSTEM_CALL, "could not open or create log file %pSE: %m", zcf->filename); - break; + return -1; case ZLOG_5424_DST_UNIX: if (!zcf->filename) - break; + return -1; memset(&sa, 0, sizeof(sa)); sa.sun_family = AF_UNIX; @@ -988,6 +993,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type) "could not connect to log unix path %pSE: %m", zcf->filename); need_reconnect = true; + /* no return -1 here, trigger retry code below */ } else { /* datagram sockets are connectionless, restarting * the receiver may lose some packets but will resume |
