Re: [PATCH] Fix fd leak in pg_dump compression backends when dup()+fdopen() fails - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH] Fix fd leak in pg_dump compression backends when dup()+fdopen() fails
Date
Msg-id 1302471.1773940095@sss.pgh.pa.us
Whole thread Raw
In response to [PATCH] Fix fd leak in pg_dump compression backends when dup()+fdopen() fails  (Jianghua Yang <yjhjstz@gmail.com>)
Responses Re: [PATCH] Fix fd leak in pg_dump compression backends when dup()+fdopen() fails
List pgsql-hackers
Jianghua Yang <yjhjstz@gmail.com> writes:
>    == The Bug ==

>    All four compression open functions use this pattern when an existing
>    file descriptor is passed in:

>        if (fd >= 0)
>            fp = fdopen(dup(fd), mode);   /* or gzdopen() */

>        if (fp == NULL)
>            return false;                 /* dup'd fd is leaked here */

>    The problem is that dup(fd) and fdopen()/gzdopen() are two separate
>    steps, and their failure modes must be handled independently:

Hmm.  You're right that we could leak the dup'd FD, but would it matter?
I'm pretty sure all these programs will just exit immediately on
failure.

I'm not averse to improving the code, but I'm not sure there is
a live bug worth back-patching.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: pg_plan_advice
Next
From: Fujii Masao
Date:
Subject: Re: pg_stat_replication.*_lag sometimes shows NULL during active replication