]> git.ipfire.org Git - thirdparty/postgresql.git/commit
libpq-oauth: Avoid overflow for very large intervals
authorJacob Champion <jchampion@postgresql.org>
Fri, 31 Jul 2026 18:08:23 +0000 (11:08 -0700)
committerJacob Champion <jchampion@postgresql.org>
Fri, 31 Jul 2026 18:08:23 +0000 (11:08 -0700)
commitb738f7b679672ced054efc36e8da21c24d3a033b
treeeed7494f2d0474931f90312a4ddc1a1301853857
parent3e8a0c1b02c3d8b96cd5febacab8aaba4869431f
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
src/interfaces/libpq-oauth/oauth-curl.c