| From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
|---|---|
| To: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
| Cc: | Jan Nidzwetzki <jan(at)planetscale(dot)com>, Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>, ♂π≌26218 <1991230470(at)qq(dot)com>, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: START_REPLICATION silently truncates an overlong LSN component |
| Date: | 2026-10-23 13:45:42 |
| Message-ID: | CAHGQGwF97J+RLnz1gewoM6Sh2XbsEHAm=ytgeUPqD8xoTB6xXQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Fri, Oct 23, 2026 at 12:24 PM Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
> Right, it should be rejected. One my primitive fix idea is to directly specify the
> acceptable strings, like [0-9A-Fa-f/]. PSA the patch.
Thanks for updating the patch!
+ if (fscanf(lfp,
+ "START WAL LOCATION: %" CppAsString2(MAXPG_LSNLEN) "[0-9A-Fa-f/]
(file %08X%16s)%c",
For portability, isn't it better to use [0123456789ABCDEFabcdef/] instead of
[0-9A-Fa-f/]? pg_parse_lsn() also lists the hexadecimal digits explicitly.
- if (fscanf(lfp, "INCREMENTAL FROM LSN: %X/%08X\n", &hi, &lo) > 0)
+ if (fscanf(lfp, "INCREMENTAL FROM LSN: %" CppAsString2(MAXPG_LSNLEN)
"[0-9A-Fa-f/]\n",
+ lsn) > 0)
This change seems to allow a backup label containing "INCREMENTAL FROM
LSN: +0/1"
to bypass the check. Previously, %X accepted the leading sign, causing fscanf()
to return a positive value and the backup to be rejected. With this scanset,
fscanf() returns zero instead.
Since we only need to detect an incremental backup here and don't use
the LSN value, how about using "%s\n" instead of "[0-9A-Fa-f/]\n"? This would
preserve the rejection of the above input while also rejecting malformed
values such as "INCREMENTAL FROM LSN: junk".
Regards,
--
Fujii Masao
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Matheus Alcantara | 2026-10-23 13:59:23 | Re: BUG #19789: "expression not found in statistics object" for a boolean domain column in an MCV statistics object |
| Previous Message | Nitin Motiani | 2026-10-23 13:14:05 | Re: BUG #19761: btree_gist: "cannot subtract infinite dates" when inserting 'infinity' into a GiST index on date |