pgsql: Add pg_add_size_overflow() and friends

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add pg_add_size_overflow() and friends
Date: 2026-05-11 12:19:40
Message-ID: E1wMPbo-0002eX-1v@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)champion(at)enterprisedb(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Discussion: https://postgr.es/m/CAOYmi%2B%3D%2BpqUd2MUitvgW1pAJuXgG_TKCVc3_Ek7pe8z9nkf%2BAg%40mail.gmail.com
Backpatch-through: 14-18
Security: CVE-2026-6473

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/37842f3dc6c2da8eb71816698e99391a0e0d4441
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>

Modified Files
--------------
src/include/common/int.h | 67 +++++++++++++++++++++++++++++++++++++
src/interfaces/libpq/fe-exec.c | 44 +++++++-----------------
src/interfaces/libpq/fe-print.c | 36 +++++---------------
src/interfaces/libpq/fe-protocol3.c | 27 +++------------
4 files changed, 91 insertions(+), 83 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-05-11 12:19:41 pgsql: Check CREATE privilege on multirange type schema in CREATE TYPE.
Previous Message Noah Misch 2026-05-11 12:19:39 pgsql: Check CREATE privilege on multirange type schema in CREATE TYPE.