[Patch] Fix bounds check in trim_array()

From: Martin Kalcher <martin(dot)kalcher(at)aboutsource(dot)net>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: [Patch] Fix bounds check in trim_array()
Date: 2022-07-25 14:40:51
Message-ID: baaeb413-b8a8-4656-5757-ef347e5ec11f@aboutsource.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
0001-Fix-bounds-check-in-trim_array.patch text/x-patch 1.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2022-07-25 14:44:28 Re: Handle infinite recursion in logical replication setup
Previous Message Thomas Munro 2022-07-25 14:35:35 Re: Cleaning up historical portability baggage