pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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: <E1xP7fs-00000000Nwf-46Tg@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_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/de51a0e294a2f21632e924d65744da089a2c9b22

Modified Files
--------------
src/backend/commands/copyfromparse.c |  4 ++++
src/test/regress/expected/copy2.out  |  8 ++++++++
src/test/regress/sql/copy2.sql       | 11 +++++++++++
3 files changed, 23 insertions(+)



view thread (4+ messages)  latest in thread

Message-ID: <E1xP7fs-00000000Nwf-46Tg@gemulon.postgresql.org>
Permalink:  ../E1xP7fs-00000000Nwf-46Tg@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xP7fs-00000000Nwf-46Tg@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 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: <E1xP7fs-00000000Nwf-46Tg@gemulon.postgresql.org>
  References: <E1xP7fs-00000000Nwf-46Tg@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