Re: pg_rewind: Fix buffer size passed when building WAL file name

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Xuneng Zhou <xunengzhou(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_rewind: Fix buffer size passed when building WAL file name
Date: 2026-11-30 13:22:42
Message-ID: e2de2848-950e-439b-861e-29fdaa6ede41@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 26.11.26 02:54, Xuneng Zhou wrote:
> Hi,
>
> On Thu, Nov 26, 2026 at 8:38 AM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>>
>>
>>
>>> On Nov 26, 2026, at 01:04, Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>>>
>>> In pg_rewind findLastCheckpoint() there is a buffer size mismatch when composing a WAL file name. You can't actually overflow the buffer, so it's harmless, but when playing with compiler annotations, I see this getting flagged, because it's rather obviously incorrect on some level, so I think it's worth fixing. See attached patch for details.
>>> <0001-pg_rewind-Fix-buffer-size-passed-when-building-WAL-f.patch>
>>
>> I see this patch actually two things:
>>
>> 1. Replacing MAXFNAMELEN with MAXPGPATH. As xlogfname is going to store a path rather than just a file name, the fix is reasonable, though we cannot overflow it today.
>>
>> 2. The current code uses snprintf() + XLogFileName(), while this patch changes it to use XLogFilePath(), which makes the code easier to read and looks like a good cleanup.
>>
>> So, the patch looks good to me.
>
> +1. Additionally, AI checked 103 calls to the eight WAL, timeline,
> archive-status, and backup filename/path helpers under src and
> contrib, and it found no similar buffer-size mismatches.
committed, thanks

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Ishjaap Singh 2026-11-30 13:05:13 Re: [DEPARSE] Column alias lists of XMLTABLE and JSON_TABLE are not printed