]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Bounds-check access to TupleDescAttr with an Assert.
authorRobert Haas <rhaas@postgresql.org>
Tue, 24 Mar 2026 12:58:50 +0000 (08:58 -0400)
committerRobert Haas <rhaas@postgresql.org>
Tue, 24 Mar 2026 12:58:50 +0000 (08:58 -0400)
commitc98ad086ad9b1ca9dbb2725f246298fa8450d82f
tree5ea09e609976f4b9e3a8dbb4fc5109d5b9fa31b0
parente2f289e5b9b82acaf1523fda827e71b8fc8bd549
Bounds-check access to TupleDescAttr with an Assert.

The second argument to TupleDescAttr should always be at least zero
and less than natts; otherwise, we index outside of the attribute
array. Assert that this is the case.

Various violations, or possible violations, of this rule that are
currently in the tree are actually harmless, because while
we do call TupleDescAttr() before verifying that the argument is
within range, we don't actually dereference it unless the argument
was within range all along. Nonetheless, the Assert means we
should be more careful, so tidy up accordingly.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: http://postgr.es/m/CA+TgmoacixUZVvi00hOjk_d9B4iYKswWP1gNqQ8Vfray-AcOCA@mail.gmail.com
src/backend/access/common/tupdesc.c
src/include/access/tupdesc.h
src/pl/plperl/plperl.c
src/pl/plpgsql/src/pl_exec.c