From 0b8ba06701c5b24eaebabeb79f62c980ddea49f5 Mon Sep 17 00:00:00 2001 From: Ana Bobillo Date: Thu, 22 Oct 2026 20:56:23 +0200 Subject: [PATCH v1 2/3] libpq: Don't trace a pre-3.0 error message as a protocol 3 message From: Ana Bobillo A server that answers the startup packet with an error message from before protocol 3.0 (servers before version 14 did so for errors raised before they read the startup packet) sends no length word. Since b8b3f861fbd sent every message received during connection startup to the tracer, such a message was traced as if its first four characters were its length, and the tracer read past its end. Don't trace it. --- src/interfaces/libpq/fe-connect.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 811cb0f2a50..9a1250b6a72 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -4088,8 +4088,13 @@ keep_going: /* We will come back to here until there is /* We'll come back when there is more data */ return PGRES_POLLING_READING; } - /* OK, we read the message; mark data consumed */ - pqParseDone(conn, conn->inCursor); + + /* + * OK, we read the message; mark data consumed. Don't + * trace it: it has no length word, so the tracer can't + * tell where it ends. + */ + conn->inStart = conn->inCursor; /* * Before 7.2, the postmaster didn't always end its