Re: Fix out-of-bounds array indexing in JsonValueList

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Tristan Partin <tristan(at)partin(dot)io>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Fix out-of-bounds array indexing in JsonValueList
Date: 2026-10-05 11:51:41
Message-ID: 1661cdd2-fb2a-4937-8242-f515b13d25b2@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 29.09.26 07:50, Peter Eisentraut wrote:
> On 29.09.26 06:04, Tristan Partin wrote:
>> When compiling Postgres with -fsanitize=bounds, I get the following
>> errors in the log:
>>
>>     jsonpath_exec.c:3832:3: runtime error: index 3 out of bounds for
>> type 'JsonbValue[2]'
>>     jsonpath_exec.c:3918:10: runtime error: index 3 out of bounds for
>> type 'JsonbValue[2]'
>
> I've run into this problem as well, but only when compiling with -
> fstrict-flex-arrays=1.  Is that what you are using?
>
> I would like to get this fixed, because this site appears to be the only
> problem of this kind.  I will check your proposal.

I played around with this a bit more and came up with the attached
solution, which is much simpler but requires that we don't go higher
than -fstrict-flex-arrays=1 -- which we can't anyway for other reasons
shown in the patch.

Attachment Content-Type Size
v1.5-0001-Add-compiler-option-fstrict-flex-arrays-1.patch text/plain 8.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Lepikhov 2026-10-05 12:04:51 Re: hashjoins vs. Bloom filters (yet again)
Previous Message Kirill Reshke 2026-10-05 11:48:16 Re: pg_dump/restore failure (dependency?) on BF serinus