]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/pager: fix improper use of negative value [coverity scan]
authorSami Kerola <kerolasa@iki.fi>
Sat, 8 Aug 2020 19:02:01 +0000 (20:02 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 16 Oct 2020 09:30:08 +0000 (11:30 +0200)
The close(2) cannot accept a negative number.

CID: 360777
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lib/pager.c

index b3cf6ee79bfcded1abd7d6d986ee9c08698898c6..747521e137dbfde24b042c8398b387b5fe5de198 100644 (file)
@@ -88,14 +88,14 @@ static int start_command(struct child_process *cmd)
        if (cmd->pid < 0) {
                if (need_in)
                        close_pair(fdin);
-               else if (cmd->in)
+               else if (0 <= cmd->in)
                        close(cmd->in);
                return -1;
        }
 
        if (need_in)
                close(fdin[0]);
-       else if (cmd->in)
+       else if (0 <= cmd->in)
                close(cmd->in);
        return 0;
 }