pgsql: Fix integer overflow in array_agg(), when the array grows too la

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix integer overflow in array_agg(), when the array grows too la
Date: 2026-05-11 12:19:41
Message-ID: E1wMPbp-0002gH-0U@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix integer overflow in array_agg(), when the array grows too large

If you accumulate many arrays full of NULLs, you could overflow
'nitems', before reaching the MaxAllocSize limit on the allocations.
Add an explicit check that the number of items doesn't grow too large.
With more than MaxArraySize items, getting the final result with
makeArrayResultArr() would fail anyway, so better to error out early.

Reported-by: Xint Code
Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Backpatch-through: 14
Security: CVE-2026-6473

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8e81995de30c5a1834d7dae56a6396067d491975
Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>

Modified Files
--------------
src/backend/utils/adt/arrayfuncs.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 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: Add raw_connect and raw_connect_works to Cluster.pm