Commit e947458
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
(cherry picked from commit 67dd6243dc95df560ff3c31ed5b6e9474d98c4c3)1 parent 073e734 commit e947458
1 file changed
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5567 | 5567 | | |
5568 | 5568 | | |
5569 | 5569 | | |
| 5570 | + | |
5570 | 5571 | | |
5571 | 5572 | | |
5572 | 5573 | | |
| |||
5596 | 5597 | | |
5597 | 5598 | | |
5598 | 5599 | | |
| 5600 | + | |
| 5601 | + | |
| 5602 | + | |
| 5603 | + | |
| 5604 | + | |
| 5605 | + | |
| 5606 | + | |
| 5607 | + | |
5599 | 5608 | | |
5600 | 5609 | | |
5601 | 5610 | | |
| |||
5661 | 5670 | | |
5662 | 5671 | | |
5663 | 5672 | | |
5664 | | - | |
5665 | | - | |
5666 | 5673 | | |
5667 | 5674 | | |
5668 | 5675 | | |
| |||
5686 | 5693 | | |
5687 | 5694 | | |
5688 | 5695 | | |
5689 | | - | |
| 5696 | + | |
5690 | 5697 | | |
5691 | 5698 | | |
5692 | 5699 | | |
| |||
0 commit comments