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>
This commit is contained in:
Karel Zak 2019-05-15 15:52:54 +02:00
parent 2c417af196
commit 8e28151329
1 changed files with 5 additions and 1 deletions

View File

@ -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)