pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: libpq: Correct processing of startup response messages
Date: Thu, 17 Nov 2022 13:40:18 +0000
Message-ID: <E1ovf7q-000bXS-1z@gemulon.postgresql.org> (raw)

libpq: Correct processing of startup response messages

After sending a startup message, libpq expects either an error
response ('E') or an authentication request ('R').  Before processing
the message, it ensures it has read enough bytes to correspond to the
length specified in the message.  However, when processing the 'R'
message, if an EOF status is returned it loops back waiting for more
input, even though we already checked that we have enough input.  In
this particular case, this is probably not reachable anyway, because
other code ensures we have enough bytes for an authentication request
message, but the code is wrong and misleading.  In the more general
case, processing a faulty message could result in an EOF status, which
would then result in an infinite loop waiting for the end of a message
that will never come.  The correction is to make this an error.

Reported-by: Jacob Champion <jchampion@timescale.com>
Discussion: https://www.postgresql.org/message-id/flat/f9c7862f-b864-8ef7-a861-c4638c83e209@enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/dce92e59b1a9ff8401a660a1ac448ea37d498284

Modified Files
--------------
src/interfaces/libpq/fe-connect.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)



Message-ID: <E1ovf7q-000bXS-1z@gemulon.postgresql.org>
Permalink:  ../E1ovf7q-000bXS-1z@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ovf7q-000bXS-1z@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org
  Subject: Re: pgsql: libpq: Correct processing of startup response messages
  In-Reply-To: <E1ovf7q-000bXS-1z@gemulon.postgresql.org>
  References: <E1ovf7q-000bXS-1z@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox