Abort if dup fail (src/bin/pg_dump/compress_none.c) - Mailing list pgsql-hackers

From Ranier Vilela
Subject Abort if dup fail (src/bin/pg_dump/compress_none.c)
Date
Msg-id CAEudQAr9fu0W9ULyT_+08v4BAn2bMU=D-VON=OwvciVRy5N_4A@mail.gmail.com
Whole thread Raw
List pgsql-hackers
Hi.

Per Coverity.
CID 1506240: (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
3. negative_returns: dup(fd) is passed to a parameter that cannot be negative.

pg_dump function open_none, tries to associate a stream to a file descriptor,
using function dup, which may fail and return negative value.

fdopen cannot receive negative parameters, in this case fail and return EBADF.

This can be confusing for the user, who will be trying to figure out what's wrong.
Better abort and report the correct failure to the user.

Patch attached.

Best regards,
Ranier Vilela


Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: pgsql: Clean pg_walsummary's tmp_check directory.
Next
From: Robert Haas
Date:
Subject: Re: Flushing large data immediately in pqcomm