pgsql: Avoid unsafe access to negative index in a TupleDesc.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid unsafe access to negative index in a TupleDesc.
Date: 2026-04-06 18:22:44
Message-ID: E1w9oax-003Gzt-2L@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid unsafe access to negative index in a TupleDesc.

Commit aa606b931 installed a test that would reference a nonexistent
TupleDesc array entry if a system column is used in COPY FROM WHERE.
Typically this would be harmless, but with bad luck it could result
in a phony "generated columns are not supported in COPY FROM WHERE
conditions" error, and at least in principle it could cause SIGSEGV.
(Compare 570e2fcc0 which fixed the identical problem in another
place.) Also, since c98ad086a it throws an Assert instead.

In the back branches, just guard the test to make it a safe no-op for
system columns. Commit 21c69dc73 installed a more aggressive answer
in master.

Reported-by: Alexander Lakhin <exclusion(at)gmail(dot)com>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/6f435023-8ab6-47c2-ba07-035d0c4212f9@gmail.com
Backpatch-through: 14-18

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3c7a6bbe63e2707c6bd50ccab64d68756e6b7c78

Modified Files
--------------
src/backend/commands/copy.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-04-06 18:49:10 pgsql: Allow autovacuum to use parallel vacuum workers.
Previous Message Álvaro Herrera 2026-04-06 18:11:59 pgsql: Rename cluster.c to repack.c (and corresponding .h)