]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Check CREATE_REPLICATION_SLOT response shape in libpqwalreceiver
authorFujii Masao <fujii@postgresql.org>
Thu, 16 Jul 2026 04:38:34 +0000 (13:38 +0900)
committerFujii Masao <fujii@postgresql.org>
Thu, 16 Jul 2026 04:39:22 +0000 (13:39 +0900)
commit0231fa2c3a8621450e51044d335725dae2338abb
tree8ba968e2cc2a2058d21f6166cb58bbfc39e43580
parent8a84ddd8c63289e14e1e1cc2c8a4a9c41f652e1a
Check CREATE_REPLICATION_SLOT response shape in libpqwalreceiver

Previously, libpqrcv_create_slot() checked only that
CREATE_REPLICATION_SLOT returned PGRES_TUPLES_OK before reading
values from the first row. If the server unexpectedly returned an
invalid result, such as zero rows, PQgetvalue() could return NULL,
leading to a crash while parsing the LSN.

Other replication commands, such as IDENTIFY_SYSTEM, already validate
the response shape before accessing result values, but
CREATE_REPLICATION_SLOT did not.

Fix this by verifying that CREATE_REPLICATION_SLOT response contains
exactly one row with four fields, and report a protocol violation otherwise.

Backpatch to all supported versions.

Bug: #19547
Reported-by: Yuelin Wang <1217816127@qq.com>
Author: Kenny Chen <kennychen851228@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/19547-f7986f668f71e788@postgresql.org
Discussion: https://postgr.es/m/CAPXstDtW2iqe+DJAOTQTX+rRziJp2UhZSo1+HRj1COAtbu+nKw@mail.gmail.com
Backpatch-through: 14
src/backend/replication/libpqwalreceiver/libpqwalreceiver.c