agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Harden PL/Perl code against "tied" Perl arrays and hashes.
Date: Mon, 10 Aug 2026 13:41:30 +0000
Message-ID: <E1wtQFu-00000000yIz-1vzN@gemulon.postgresql.org> (raw)

Harden PL/Perl code against "tied" Perl arrays and hashes.

Tied arrays might report different sizes each time they are inspected.
To avoid generating a corrupt result array, fix plperl_array_to_datum()
to read av_len() of each input array only once.  If the input does
appear to get shorter, we'll fill nulls for the now-missing entries,
which seems fine.  Conversely, if it gets longer, we'll ignore the new
entries.

plperl_to_hstore() assumed that Perl's hv_iterinit() returns the
number of entries in the given Perl hash.  Usually that's true,
but per the Perl docs, "the return value is currently only meaningful
for hashes without tie magic".  That could potentially end in a memory
stomp.  We don't depend on that result value anywhere else, so don't
do so here either.

Reported-by: Hcamael <baiyjrh@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Backpatch-through: 14
Security: CVE-2026-14670

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cf4ae7c3bff2e22f3fb1a92a4cbaefb40a482251
Author: Tom Lane <tgl@sss.pgh.pa.us>

Modified Files
--------------
contrib/hstore_plperl/hstore_plperl.c | 11 +++++++++--
src/pl/plperl/plperl.c                |  6 +++++-
2 files changed, 14 insertions(+), 3 deletions(-)



view thread (6+ messages)

Message-ID: <E1wtQFu-00000000yIz-1vzN@gemulon.postgresql.org>
Permalink:  ../E1wtQFu-00000000yIz-1vzN@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wtQFu-00000000yIz-1vzN@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: noah@leadboat.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Harden PL/Perl code against "tied" Perl arrays and hashes.
  In-Reply-To: <E1wtQFu-00000000yIz-1vzN@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox