]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix integer overflow in array_agg(), when the array grows too large
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
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)
commit3c41f5534aa60402293e7a50c4e44f7d6b6e3e4d
tree27a061a5f732df0088a8adbbcfafd1fbda53e166
parent26dd3cac20baa8f3ad4c8aca68351c881f92801c
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.linnakangas@iki.fi>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-6473
src/backend/utils/adt/arrayfuncs.c