]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Add pg_add_size_overflow() and friends
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 11 May 2026 12:13:49 +0000 (05:13 -0700)
committerNoah Misch <noah@leadboat.com>
Mon, 11 May 2026 12:13:49 +0000 (05:13 -0700)
commit924b3e94390de04b0fbb55edce8a29873a5062e1
treea1fb1ae6cd8e698c584146b0373d6bef30f8fbef
parent5919e0005b6f23292450a44f1db5c6b2e2bb0ddf
Add pg_add_size_overflow() and friends

Commit 600086f47 added (several bespoke copies of) size_t addition with
overflow checks to libpq. Move this to common/int.h, along with
its subtraction and multiplication counterparts.

pg_neg_size_overflow() is intentionally omitted; I'm not sure we should
add SSIZE_MAX to win32_port.h for the sake of a function with no
callers.

Back-patch of commit 8934f2136, done now because pg_add_size_overflow()
and friends are needed more widely for security fixes.

Author: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAOYmi%2B%3D%2BpqUd2MUitvgW1pAJuXgG_TKCVc3_Ek7pe8z9nkf%2BAg%40mail.gmail.com
Backpatch-through: 14-18
Security: CVE-2026-6473
src/include/common/int.h
src/interfaces/libpq/fe-exec.c
src/interfaces/libpq/fe-print.c
src/interfaces/libpq/fe-protocol3.c