pgsql: Avoid overflow in size calculations in formatting.c.

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid overflow in size calculations in formatting.c.
Date: 2026-05-11 12:19:41
Message-ID: E1wMPbp-0002g6-0G@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid overflow in size calculations in formatting.c.

A few functions in this file were incautious about multiplying a
possibly large integer by a factor more than 1 and then using it as
an allocation size. This is harmless on 64-bit systems where we'd
compute a size exceeding MaxAllocSize and then fail, but on 32-bit
systems we could overflow size_t, leading to an undersized
allocation and buffer overrun. To fix, use palloc_array() or
mul_size() instead of handwritten multiplication.

Reported-by: Sven Klemm <sven(at)tigerdata(dot)com>
Reported-by: Xint Code
Author: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Security: CVE-2026-6473
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/98675336195b526edc69890d68a1dc0408d63b3f
Author: Nathan Bossart <nathan(at)postgresql(dot)org>

Modified Files
--------------
src/backend/utils/adt/formatting.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-05-11 13:40:29 Re: pgsql: Release notes for 18.4, 17.10, 16.14, 15.18, 14.23.
Previous Message Noah Misch 2026-05-11 12:19:40 pgsql: Harden our regex engine against integer overflow in size calcula