From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix use-after-free in COPY (ON_ERROR)
Date: Fri, 06 Nov 2026 00:19:20 +0000
Message-ID: <E1xP7ft-00000000Nwk-05ny@gemulon.postgresql.org> (raw)
Fix use-after-free in COPY (ON_ERROR)
When ON_ERROR handled a soft error, some of the contents set for the
error context callback could remain set and pointing at areas that could
be reset, leading to some use-after-frees depending on the input data
provided through COPY.
These contents are now reset at the beginning of NextCopyFrom(), before
processing the next tuple.
SET_NULL is affected down to v19, IGNORE down to v17.
Author: Gowdham M <gowdham.m@zohocorp.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Discussion: https://postgr.es/m/1a181ff6be8.6d14feb261368.4036709598649280477@zohocorp.com
Backpatch-through: 17
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/61b06d2ba61d04398585d6d06b1ee5f4cd53c3b5
Modified Files
--------------
src/backend/commands/copyfromparse.c | 4 ++++
src/test/regress/expected/copy2.out | 4 ++++
src/test/regress/sql/copy2.sql | 6 ++++++
3 files changed, 14 insertions(+)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: michael@paquier.xyz
Subject: Re: pgsql: Fix use-after-free in COPY (ON_ERROR)
In-Reply-To: <E1xP7ft-00000000Nwk-05ny@gemulon.postgresql.org>
References: <E1xP7ft-00000000Nwk-05ny@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox