agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: libpq-oauth: Avoid overflow for very large intervals
3+ messages / 1 participants
[nested] [flat]

* pgsql: libpq-oauth: Avoid overflow for very large intervals
@ 2026-07-31 18:27 Jacob Champion <jchampion@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Jacob Champion @ 2026-07-31 18:27 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

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

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: libpq-oauth: Avoid overflow for very large intervals
@ 2026-07-31 18:27 Jacob Champion <jchampion@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Jacob Champion @ 2026-07-31 18:27 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: libpq-oauth: Avoid overflow for very large intervals
@ 2026-07-31 18:27 Jacob Champion <jchampion@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Jacob Champion @ 2026-07-31 18:27 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/74169d3a1d695556ad81ef7a9c256daf0d554da1

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-07-31 18:27 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-31 18:27 pgsql: libpq-oauth: Avoid overflow for very large intervals Jacob Champion <jchampion@postgresql.org>
2026-07-31 18:27 pgsql: libpq-oauth: Avoid overflow for very large intervals Jacob Champion <jchampion@postgresql.org>
2026-07-31 18:27 pgsql: libpq-oauth: Avoid overflow for very large intervals Jacob Champion <jchampion@postgresql.org>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox