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: Fix trim_array() for zero-dimensional array argument.
Date: Sun, 31 Jul 2022 17:43:29 +0000
Message-ID: <E1oICyO-0026tX-7H@gemulon.postgresql.org> (raw)

Fix trim_array() for zero-dimensional array argument.

The code tried to access ARR_DIMS(v)[0] and ARR_LBOUND(v)[0]
whether or not those values exist.  This made the range check
on the "n" argument unstable --- it might or might not fail, and
if it did it would report garbage for the allowed upper limit.
These bogus accesses would probably annoy Valgrind, and if you
were very unlucky even lead to SIGSEGV.

Report and fix by Martin Kalcher.  Back-patch to v14 where this
function was added.

Discussion: https://postgr.es/m/baaeb413-b8a8-4656-5757-ef347e5ec11f@aboutsource.net

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e71d4254f710bef53fa40d0b49b5af9bad10ce40

Modified Files
--------------
src/backend/utils/adt/arrayfuncs.c   | 9 ++++++---
src/test/regress/expected/arrays.out | 2 ++
src/test/regress/sql/arrays.sql      | 1 +
3 files changed, 9 insertions(+), 3 deletions(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1oICyO-0026tX-7H@gemulon.postgresql.org>
Permalink:  ../E1oICyO-0026tX-7H@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oICyO-0026tX-7H@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix trim_array() for zero-dimensional array argument.
  In-Reply-To: <E1oICyO-0026tX-7H@gemulon.postgresql.org>
  References: <E1oICyO-0026tX-7H@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