From: Karel Zak Date: Wed, 15 May 2019 13:52:54 +0000 (+0200) Subject: lib/path: fix ul_path_get_dirfd() usage [coverity scan] X-Git-Tag: v2.34-rc2~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8e2815132911e20921db11767832c64ee5c5e3b1;p=thirdparty%2Futil-linux.git lib/path: fix ul_path_get_dirfd() usage [coverity scan] ul_path_get_dirfd() returns negative number on error... Signed-off-by: Karel Zak --- diff --git a/lib/path.c b/lib/path.c index 968ce9114d..9b05f4b98a 100644 --- a/lib/path.c +++ b/lib/path.c @@ -436,8 +436,12 @@ DIR *ul_path_opendir(struct path_cxt *pc, const char *path) if (path) fd = ul_path_open(pc, O_RDONLY|O_CLOEXEC, path); else if (pc->dir_path) { + int dirfd; + DBG(CXT, ul_debugobj(pc, "duplicate dir path")); - fd = dup_fd_cloexec(ul_path_get_dirfd(pc), STDERR_FILENO + 1); + dirfd = ul_path_get_dirfd(pc); + if (dirfd >= 0) + fd = dup_fd_cloexec(dirfd, STDERR_FILENO + 1); } if (fd < 0)