pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: In array_position()/array_positions(), beware of empty input arr
Date: Thu, 04 May 2023 15:48:40 +0000
Message-ID: <E1pubCB-000Sk8-U5@gemulon.postgresql.org> (raw)

In array_position()/array_positions(), beware of empty input array.

These functions incautiously fetched the array's first lower bound
even when the array is zero-dimensional, thus fetching the word
after the allocated array space.  While almost always harmless,
with very bad luck this could result in SIGSEGV.  Fix by adding
an early exit for empty input.

Per bug #17920 from Alexander Lakhin.

Discussion: https://postgr.es/m/17920-f7c228c627b6d02e%40postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9a72f499a4b61c34e3ae7759c209e92e0cfef6e1

Modified Files
--------------
src/backend/utils/adt/array_userfuncs.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1pubCB-000Sk8-U5@gemulon.postgresql.org>
Permalink:  ../E1pubCB-000Sk8-U5@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pubCB-000Sk8-U5@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: In array_position()/array_positions(), beware of empty input arr
  In-Reply-To: <E1pubCB-000Sk8-U5@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox