agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Jacob Champion <jchampion@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: libpq-oauth: Avoid overflow for very large intervals
Date: Fri, 31 Jul 2026 18:27:10 +0000
Message-ID: <E1wprws-0000000182p-22cs@gemulon.postgresql.org> (raw)

libpq-oauth: Avoid overflow for very large intervals

The slow_down interval parsing code checks explicitly for overflow, but
since it does that after the signed overflow has already occurred, we
end up inviting undefined behavior from the compiler anyway.

Use checked arithmetic instead. set_timer() takes a long int in order to
interface nicely with libcurl, so use an int32 as the interval counter
and clamp to LONG_MAX during conversion to milliseconds.

Backpatch to 18, where libpq-oauth was introduced.

Reported-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/qtclihmrkq67ach3xjxyi4qcksstin5qxwsnkqefkmotxwh4g6%40ae2bj6jvcmry
Backpatch-through: 18

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/19ff9a1ae04087ff324dc2180c757d56258ab89a

Modified Files
--------------
src/interfaces/libpq-oauth/oauth-curl.c | 35 +++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1wprws-0000000182p-22cs@gemulon.postgresql.org>
Permalink:  ../E1wprws-0000000182p-22cs@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wprws-0000000182p-22cs@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: jchampion@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: libpq-oauth: Avoid overflow for very large intervals
  In-Reply-To: <E1wprws-0000000182p-22cs@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