[Patch] Fix bounds check in trim_array()
Martin Kalcher <martin.kalcher@aboutsource.net>
From: Martin Kalcher <martin.kalcher@aboutsource.net>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-07-25T14:40:51Z
Lists: pgsql-hackers
Attachments
- 0001-Fix-bounds-check-in-trim_array.patch (text/x-patch) patch 0001
Hi,
while working on something else i encountered a bug in the trim_array()
function. The bounds check fails for empty arrays without any
dimensions. It reads the size of the non existing first dimension to
determine the arrays length.
select trim_array('{}'::int[], 10);
------------
{}
select trim_array('{}'::int[], 100);
ERROR: number of elements to trim must be between 0 and 64
The attached patch fixes that check.
Martin
Commits
-
Fix trim_array() for zero-dimensional array argument.
- e71d4254f710 14.5 landed
- d386b75df553 15.0 landed
- 4ddfbd2a8ea9 16.0 landed