| From: | Richard Guo <rguo(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: plperl: Fix NULL pointer dereference for forged array object |
| Date: | 2026-06-24 00:18:36 |
| Message-ID: | E1wcBK8-001bCg-0s@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
plperl: Fix NULL pointer dereference for forged array object
In get_perl_array_ref(), for a PostgreSQL::InServer::ARRAY object, we
look up its "array" key with hv_fetch_string() and then inspect the
returned SV. However, hv_fetch_string() returns a NULL pointer when
the key is absent, and the code dereferenced that result without first
checking whether the pointer itself was NULL. As a result, a plperl
function returning a forged PostgreSQL::InServer::ARRAY object that
lacks the "array" key would crash the backend with a segmentation
fault.
Fix this by checking the pointer returned by hv_fetch_string() before
dereferencing it, matching how other callers in this file already
guard the result. With the check in place, such an object falls
through to the existing error report instead of crashing.
Author: Xing Guo <higuoxing(at)gmail(dot)com>
Reviewed-by: Richard Guo <guofenglinux(at)gmail(dot)com>
Discussion: https://postgr.es/m/CACpMh+DYgcnqZwQLXXuxQcehJTd7T8UmKWSLsK4mFBEp9G2ajA@mail.gmail.com
Backpatch-through: 14
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/9b2a6ccc4793d19d06bd0926367011476157295c
Modified Files
--------------
src/pl/plperl/expected/plperl_array.out | 7 +++++++
src/pl/plperl/plperl.c | 2 +-
src/pl/plperl/sql/plperl_array.sql | 7 +++++++
3 files changed, 15 insertions(+), 1 deletion(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Langote | 2026-06-24 01:08:37 | Re: pgsql: Re-index ModifyTable FDW arrays when pruning result relations |
| Previous Message | Amit Langote | 2026-06-24 00:00:11 | pgsql: Re-index ModifyTable FDW arrays when pruning result relations |