pgsql: libpq-oauth: Avoid overflow for very large intervals - Mailing list pgsql-committers

From Jacob Champion
Subject pgsql: libpq-oauth: Avoid overflow for very large intervals
Date
Msg-id E1wprws-0000000182t-2Dcd@gemulon.postgresql.org
Whole thread
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Nathan Bossart
Date:
Subject: pgsql: Fix autovacuum's database sorting.
Next
From: Tom Lane
Date:
Subject: pgsql: On Windows, make link(2) report ENOTSUP when appropriate.