Bounds-check access to TupleDescAttr with an Assert.
Robert Haas <rhaas@postgresql.org>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/common/tupdesc.c | modified | +15 −12 |
| src/include/access/tupdesc.h | modified | +2 −0 |
| src/pl/plperl/plperl.c | modified | +5 −2 |
| src/pl/plpgsql/src/pl_exec.c | modified | +4 −2 |
Discussion
- TupleDescAttr bounds checks 13 messages · 2026-03-20 → 2026-04-05