postgresql/src/pl/plperl
Richard Guo 4015abe14b 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@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CACpMh+DYgcnqZwQLXXuxQcehJTd7T8UmKWSLsK4mFBEp9G2ajA@mail.gmail.com
Backpatch-through: 14
2026-06-24 09:09:48 +09:00
..
expected plperl: Fix NULL pointer dereference for forged array object 2026-06-24 09:09:48 +09:00
po Translation updates 2026-06-01 12:13:54 +02:00
sql plperl: Fix NULL pointer dereference for forged array object 2026-06-24 09:09:48 +09:00
.gitignore Allow make check in PL directories 2011-02-15 06:52:12 +02:00
GNUmakefile EUC_CN, EUC_JP, EUC_KR, EUC_TW: Skip U+00A0 tests instead of failing. 2026-02-25 18:13:22 -08:00
meson.build EUC_CN, EUC_JP, EUC_KR, EUC_TW: Skip U+00A0 tests instead of failing. 2026-02-25 18:13:22 -08:00
nls.mk Revert "Use wildcards instead of manually-maintained file lists in */nls.mk." 2022-07-13 14:29:10 -04:00
plc_perlboot.pl Update copyright for 2026 2026-01-01 13:24:10 -05:00
plc_trusted.pl Update copyright for 2026 2026-01-01 13:24:10 -05:00
plperl--1.0.sql Invent "trusted" extensions, and remove the pg_pltemplate catalog. 2020-01-29 18:42:43 -05:00
plperl.c plperl: Fix NULL pointer dereference for forged array object 2026-06-24 09:09:48 +09:00
plperl.control Invent "trusted" extensions, and remove the pg_pltemplate catalog. 2020-01-29 18:42:43 -05:00
plperl.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
plperl_opmask.pl Update copyright for 2026 2026-01-01 13:24:10 -05:00
plperl_system.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
plperlu--1.0.sql Invent "trusted" extensions, and remove the pg_pltemplate catalog. 2020-01-29 18:42:43 -05:00
plperlu.control Create extension infrastructure for the core procedural languages. 2011-03-04 21:51:14 -05:00
ppport.h Remove HP-UX port. 2022-07-08 14:05:05 +12:00
README Stop generating plain-text INSTALL instructions. 2023-12-22 13:32:15 -05:00
SPI.xs Be more careful to avoid including system headers after perl.h 2022-08-27 14:45:18 +07:00
text2macro.pl Update copyright for 2026 2026-01-01 13:24:10 -05:00
Util.xs New header varatt.h split off from postgres.h 2023-01-10 05:54:36 +01:00

src/pl/plperl/README

PL/Perl allows you to write PostgreSQL functions and procedures in
Perl.  To include PL/Perl in the build use './configure --with-perl'.
To build from this directory use 'make all; make install'.  libperl
must have been built as a shared library, which is usually not the
case in standard installations.

Consult the PostgreSQL User's Guide for more information.