diff options
author | Karel Zak | 2019-05-15 15:52:54 +0200 |
---|---|---|
committer | Karel Zak | 2019-05-15 15:52:54 +0200 |
commit | 8e2815132911e20921db11767832c64ee5c5e3b1 (patch) | |
tree | 95ce1663c4174a9df6b1dc4ce4d7d6a97a0b3290 /lib | |
parent | lib/path: consolidate ul_path_mkpath() usage (diff) | |
download | kernel-qcow2-util-linux-8e2815132911e20921db11767832c64ee5c5e3b1.tar.gz kernel-qcow2-util-linux-8e2815132911e20921db11767832c64ee5c5e3b1.tar.xz kernel-qcow2-util-linux-8e2815132911e20921db11767832c64ee5c5e3b1.zip |
lib/path: fix ul_path_get_dirfd() usage [coverity scan]
ul_path_get_dirfd() returns negative number on error...
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/path.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/path.c b/lib/path.c index 968ce9114..9b05f4b98 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) |