pgsql: Fix trim_array() for zero-dimensional array argument.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix trim_array() for zero-dimensional array argument.
Date: 2022-07-31 17:43:29
Message-ID: E1oICyO-0026tU-6s@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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_15_STABLE

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

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2022-07-31 19:42:58 pgsql: ci: switch to freebsd 13.1
Previous Message Tom Lane 2022-07-31 16:30:00 pgsql: Make new auto_explain test safe for log_error_verbosity = verbos