summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2023-09-20 14:35:55 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2023-09-20 14:35:55 +0200
commit5ce8577bd77f97758a24cbfec8e90513a5abcb12 (patch)
tree615155cb286bcd9d93495ebd61db5273b6b5388c
parentMerge pull request #14448 from qlyoung/doc-add-northbound-api-docs (diff)
downloadfrr-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.c5
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)) {