]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: add dup() error check in logging code
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 20 Sep 2023 12:35:55 +0000 (14:35 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Wed, 20 Sep 2023 12:35:55 +0000 (14:35 +0200)
Mostly to make coverity happy, if dup() fails we're f*cked already.
(Still useful to have a better error message...)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/zlog_5424.c

index c15bdece299e5621f14a4c71d57e101d3d007522..16f348369e0affbfa0c22e48fd994ad2416b2421 100644 (file)
@@ -881,6 +881,11 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
 
        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?)");
+                       break;
+               }
 
                optlen = sizeof(sock_type);
                if (!getsockopt(fd, SOL_SOCKET, SO_TYPE, &sock_type, &optlen)) {