From: | Ted Yu <yuzhihong(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org, peter(at)eisentraut(dot)org |
Subject: | Re: closing file in adjust_data_dir |
Date: | 2022-11-15 22:34:45 |
Message-ID: | CALte62zszyrTh_PhVP6ytZUv7WBf+eRMPGD2SnjMkKzTL3u+xQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Nov 15, 2022 at 10:43 AM Ted Yu <yuzhihong(at)gmail(dot)com> wrote:
> Hi,
> I was looking at the commit:
>
> commit 2fe3bdbd691a5d11626308e7d660440be6c210c8
> Author: Peter Eisentraut <peter(at)eisentraut(dot)org>
> Date: Tue Nov 15 15:35:37 2022 +0100
>
> Check return value of pclose() correctly
>
> In src/bin/pg_ctl/pg_ctl.c :
>
> if (fd == NULL || fgets(filename, sizeof(filename), fd) == NULL ||
> pclose(fd) != 0)
>
> If the fgets() call doesn't return NULL, the pclose() would be skipped.
> Since the original pclose() call was removed, wouldn't this lead to fd
> leaking ?
>
> Please see attached patch for my proposal.
>
> Cheers
>
There was potential leak of fd in patch v1.
Please take a look at patch v2.
Thanks
Attachment | Content-Type | Size |
---|---|---|
pg-ctl-close-fd-v2.patch | application/octet-stream | 751 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-11-15 22:53:27 | Re: Slow standby snapshot |
Previous Message | Greg Stark | 2022-11-15 21:58:10 | Re: Add palloc_aligned() to allow arbitrary power of 2 memory alignment |