Re: libpq support for NegotiateProtocolVersion
Jacob Champion <jchampion@timescale.com>
From: Jacob Champion <jchampion@timescale.com>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>,
Nathan Bossart <nathandbossart@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-11-02T19:02:09Z
Lists: pgsql-hackers
A few notes:
> + else if (beresp == 'v')
> + {
> + if (pqGetNegotiateProtocolVersion3(conn))
> + {
> + /* We'll come back when there is more data */
> + return PGRES_POLLING_READING;
> + }
> + /* OK, we read the message; mark data consumed */
> + conn->inStart = conn->inCursor;
> + goto error_return;
> + }
This new code path doesn't go through the message length checks that are
done for the 'R' and 'E' cases, and pqGetNegotiateProtocolVersion3()
doesn't take the message length to know where to stop anyway, so a
misbehaving server can chew up client resources.
It looks like the server is expecting to be able to continue the
conversation with a newer client after sending a
NegotiateProtocolVersion. Is an actual negotiation planned for the future?
I think the documentation on NegotiateProtocolVersion (not introduced in
this patch) is misleading/wrong; it says that the version number sent
back is the "newest minor protocol version supported by the server for
the major protocol version requested by the client" which doesn't seem
to match the actual usage seen here.
Thanks,
--Jacob
Commits
-
libpq: Handle NegotiateProtocolVersion message
- bbf9c282ce92 16.0 landed
-
libpq: Correct processing of startup response messages
- dce92e59b1a9 16.0 landed