postgresql/src
Nathan Bossart 32c525eb67 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@tigerdata.com>
Reported-by: Xint Code
Author: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Security: CVE-2026-6473
Backpatch-through: 14
2026-05-11 05:13:50 -07:00
..
backend Avoid overflow in size calculations in formatting.c. 2026-05-11 05:13:50 -07:00
bin Translation updates 2026-05-11 13:07:36 +02:00
common Unify src/common/'s definitions of MaxAllocSize. 2026-05-11 05:13:49 -07:00
fe_utils In fmtIdEnc(), handle failure of enlargePQExpBuffer(). 2025-02-16 12:46:35 -05:00
include Add timingsafe_bcmp(), for constant-time memory comparison 2026-05-11 05:13:49 -07:00
interfaces Apply timingsafe_bcmp() in authentication paths 2026-05-11 05:13:49 -07:00
makefiles Use --strip-unneeded when stripping static libraries with GNU strip. 2023-04-20 18:12:32 -04:00
pl Make plpgsql_trap test more robust and less resource-intensive. 2026-04-21 10:54:39 -04:00
port Add timingsafe_bcmp(), for constant-time memory comparison 2026-05-11 05:13:49 -07:00
template Use unnamed POSIX semaphores on Cygwin. 2023-01-06 10:33:28 +13:00
test Check CREATE privilege on multirange type schema in CREATE TYPE. 2026-05-11 05:13:50 -07:00
timezone Guard against unsafe conditions in usage of pg_strftime(). 2026-05-11 05:13:50 -07:00
tools Add timingsafe_bcmp(), for constant-time memory comparison 2026-05-11 05:13:49 -07:00
tutorial Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
.gitignore
DEVELOPERS
Makefile Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
Makefile.global.in Don't put library-supplied -L/-I switches before user-supplied ones. 2025-07-29 15:17:41 -04:00
Makefile.shlib Stop using "-multiply_defined suppress" on macOS. 2023-09-26 21:06:21 -04:00
meson.build Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
nls-global.mk Fix update-po for the PGXS case 2025-10-16 20:21:05 +02:00