[PATCH] Fix unbounded authentication exchanges during PQconnectPoll()

2023-02-13 Thread Jacob Champion
Hello, This is closely related to the prior conversation at [1]. There are a couple places in CONNECTION_AWAITING_RESPONSE where libpq will read a huge number of bytes from a server that we really should have hung up on. The attached patch adds a length check for the v2 error compatibility case,

Re: [PATCH] Fix unbounded authentication exchanges during PQconnectPoll()

2023-02-21 Thread Heikki Linnakangas
On 14/02/2023 01:22, Jacob Champion wrote: Hello, This is closely related to the prior conversation at [1]. There are a couple places in CONNECTION_AWAITING_RESPONSE where libpq will read a huge number of bytes from a server that we really should have hung up on. The attached patch adds a lengt

Re: [PATCH] Fix unbounded authentication exchanges during PQconnectPoll()

2023-02-22 Thread Jacob Champion
On Tue, Feb 21, 2023 at 12:35 PM Heikki Linnakangas wrote: > I don't think the "overlong" or "truncated" bit is helpful. For example, > if the pre-v3.0 error message seems to be "overlong", it's not clear > that's really what happened. More likely, it's just garbage. I think this is maybe a disti

Re: [PATCH] Fix unbounded authentication exchanges during PQconnectPoll()

2023-02-22 Thread Heikki Linnakangas
On 22/02/2023 20:49, Jacob Champion wrote: On Tue, Feb 21, 2023 at 12:35 PM Heikki Linnakangas wrote: @@ -3370,6 +3389,7 @@ keep_going: /* We will come back to here until there is /* Get the type of request. */

Re: [PATCH] Fix unbounded authentication exchanges during PQconnectPoll()

2023-02-22 Thread Jacob Champion
On Wed, Feb 22, 2023 at 11:43 AM Heikki Linnakangas wrote: > I separated the earlier message-length checks so that you get "invalid > invalid authentication request" or "received invalid protocol > negotiation message", depending on whether it was an 'R' or 'v' message. > With that, "invalid inval