aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeModifyTable.c
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2023-09-29 16:58:32 +1300
committerDavid Rowley <drowley@postgresql.org>2023-09-29 16:58:32 +1300
commitd40d8272190ce5f1641b9afb83a3752101af6a38 (patch)
treeaa15faf5ae0fb08ff7eec680c8ce65c5e8b4ef62 /src/backend/executor/nodeModifyTable.c
parent3ef18a90bdeaeb7895b16431b0bb0023265c1df4 (diff)
downloadpostgresql-d40d8272190ce5f1641b9afb83a3752101af6a38.tar.gz
postgresql-d40d8272190ce5f1641b9afb83a3752101af6a38.zip
Robustify find_base_rel and find_base_rel_ignore_join
Improve find_base_rel() and find_base_rel_ignore_join() so that they raise an ERROR if they ever receive a negative relid value in non-cassert builds. If either of these functions had ever received a negative relid then they'd have attempted to access memory that does not belong to simple_rel_array. Because no evidence has been presented of actual cases where bugs have caused this to happen, here we take a lightweight approach to checking for negative values and simply cast both values to uint32 before performing the comparison. This will cause any negative relids to be seen as greater than simple_rel_array_size which will ERROR rather than attempt to access a negative simple_rel_array element. Obviously, the run-time error is better than a crash, so it makes sense to protect against this, especially when it can be done without adding any additional run-time overhead. There is a slight change here if the functions are ever called with a relid of 0. This will pass the bounds check, but that array entry should be NULL (along with the corresponding simple_rte_array entry), so won't pass the "if (rel)" condition and still fall through and raise an ERROR. Author: Ranier Vilela Reviewed-by: Ashutosh Bapat, David Rowley Discussion: https://postgr.es/m/CAEudQArQSghBu2gLojg4o_tnHj_x2HcS%3D%2BwewL3NJS8z0VnK%2Bg%40mail.gmail.com
Diffstat (limited to 'src/backend/executor/nodeModifyTable.c')
0 files changed, 0 insertions, 0 deletions