Abort if dup fail (src/bin/pg_dump/compress_none.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Abort if dup fail (src/bin/pg_dump/compress_none.c)
Date: 2024-01-31 17:12:00
Message-ID: CAEudQAr9fu0W9ULyT_+08v4BAn2bMU=D-VON=OwvciVRy5N_4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
abort-if-dup-fail-pg_dump.patch application/octet-stream 599 bytes

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-01-31 17:22:48 Re: Flushing large data immediately in pqcomm
Previous Message Robert Haas 2024-01-31 17:07:53 Re: pgsql: Clean pg_walsummary's tmp_check directory.