diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2023-09-20 14:35:55 +0200 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2023-09-20 14:35:55 +0200 |
commit | 5ce8577bd77f97758a24cbfec8e90513a5abcb12 (patch) | |
tree | 615155cb286bcd9d93495ebd61db5273b6b5388c | |
parent | Merge pull request #14448 from qlyoung/doc-add-northbound-api-docs (diff) | |
download | frr-5ce8577bd77f97758a24cbfec8e90513a5abcb12.tar.xz frr-5ce8577bd77f97758a24cbfec8e90513a5abcb12.zip |
lib: add dup() error check in logging code
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>
-rw-r--r-- | lib/zlog_5424.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/zlog_5424.c b/lib/zlog_5424.c index c15bdece2..16f348369 100644 --- a/lib/zlog_5424.c +++ b/lib/zlog_5424.c @@ -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)) { |