Re: [PATCH v1] PL/Perl: Fix NULL deref for forged array - Mailing list pgsql-hackers

From Richard Guo
Subject Re: [PATCH v1] PL/Perl: Fix NULL deref for forged array
Date
Msg-id CAMbWs4_9UFW=BMZ5O19MyeHDMoLjNCPS_8WH21wCDyxY-YpMGw@mail.gmail.com
Whole thread
List pgsql-hackers
On Tue, Jun 23, 2026 at 3:47 PM Xing Guo <higuoxing@gmail.com> wrote:
> A PL/Perl function returning a forged PostgreSQL::InServer::ARRAY
> object (e.g., an empty hash blessed as that class) could cause a
> segfault. This occurs because hv_fetch_string returns NULL pointer
> when the "array" key is missing, and the code previously dereferenced
> it without checking if the pointer itself was NULL.

+1.  Good catch.  Every other caller of hv_fetch_string checks the
returned pointer.  This is the only place missing that safety check.

- Richard



pgsql-hackers by date:

Previous
From: Richard Guo
Date:
Subject: Re: Remove inner joins based on foreign keys
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements