agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Check CREATE_REPLICATION_SLOT response shape in libpqwalreceiver
Date: Thu, 16 Jul 2026 04:41:24 +0000
Message-ID: <E1wkDuV-000ObQ-3C@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3cf5264557bee2ba848e5276beecc10571d468a6

Modified Files
--------------
src/backend/replication/libpqwalreceiver/libpqwalreceiver.c | 8 ++++++++
1 file changed, 8 insertions(+)



view thread (7+ messages)  latest in thread

Message-ID: <E1wkDuV-000ObQ-3C@gemulon.postgresql.org>
Permalink:  ../E1wkDuV-000ObQ-3C@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wkDuV-000ObQ-3C@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: fujii@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Check CREATE_REPLICATION_SLOT response shape in libpqwalreceiver
  In-Reply-To: <E1wkDuV-000ObQ-3C@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox