postgresql/src/backend
Tom Lane 1f229f4fdc Teach contain_leaked_vars that assignment SubscriptingRefs are leaky.
array_get_element and array_get_slice qualify as leakproof, since
they will silently return NULL for bogus subscripts.  But
array_set_element and array_set_slice throw errors for such cases,
making them clearly not leakproof.  contain_leaked_vars was evidently
written with only the former case in mind, as it gave the wrong answer
for assignment SubscriptingRefs (nee ArrayRefs).

This would be a live security bug, were it not that assignment
SubscriptingRefs can only occur in INSERT and UPDATE target lists,
while we only care about leakproofness for qual expressions; so the
wrong answer can't occur in practice.  Still, that's a rather shaky
answer for a security-related question; and maybe in future somebody
will want to ask about leakproofness of a tlist.  So it seems wise to
fix and even back-patch this correction.

(We would need some change here anyway for the upcoming
generic-subscripting patch, since extensions might make different
tradeoffs about whether to throw errors.  Commit 558d77f20 attempted
to lay groundwork for that by asking check_functions_in_node whether a
SubscriptingRef contains leaky functions; but that idea fails now that
the implementation methods of a SubscriptingRef are not SQL-visible
functions that could be marked leakproof or not.)

Back-patch to 9.6.  While 9.5 has the same issue, the code's a bit
different.  It seems quite unlikely that we'd introduce any actual bug
in the short time 9.5 has left to live, so the work/risk/reward balance
isn't attractive for changing 9.5.

Discussion: https://postgr.es/m/3143742.1607368115@sss.pgh.pa.us
2020-12-08 17:50:54 -05:00
..
access Remove duplicate code in brin_memtuple_initialize 2020-11-11 18:54:54 +01:00
bootstrap Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:13 -07:00
catalog Fix misleading error message about inconsistent moving-aggregate types. 2020-09-06 12:55:44 -04:00
commands Avoid memcpy() with a NULL source pointer and count == 0 2020-12-01 11:46:56 -03:00
executor Properly check index mark/restore in ExecSupportsMarkRestore. 2020-11-24 21:18:37 +00:00
foreign Remove bogus "extern" annotations on function definitions. 2018-02-19 12:07:44 -05:00
jit jit: Correct parameter type for generated expression evaluation functions. 2020-12-07 18:40:27 -08:00
lib Rename rbtree.c functions to use "rbt" prefix not "rb" prefix. 2018-11-06 13:25:24 -05:00
libpq Fix unportable use of getnameinfo() in pg_hba_file_rules view. 2020-11-02 21:11:50 -05:00
main Update copyright for 2018 2018-01-02 23:30:12 -05:00
nodes Ensure that expandTableLikeClause() re-examines the same table. 2020-12-01 14:02:28 -05:00
optimizer Teach contain_leaked_vars that assignment SubscriptingRefs are leaky. 2020-12-08 17:50:54 -05:00
parser Ensure that expandTableLikeClause() re-examines the same table. 2020-12-01 14:02:28 -05:00
partitioning Do not return NULL for error cases in satisfies_hash_partition(). 2020-11-16 16:39:59 -05:00
po Translation updates 2020-11-09 12:39:47 +01:00
port Fix race condition in our Windows signal emulation. 2019-12-09 15:03:51 -05:00
postmaster In the postmaster, rely on the signal infrastructure to block signals. 2020-10-15 12:50:57 -04:00
regex Fix misoptimization of "{1,1}" quantifiers in regular expressions. 2019-05-12 18:53:40 -04:00
replication doc: wire protocol data type for history file content is bytea 2020-11-12 14:33:28 -05:00
rewrite Make rewriter prevent auto-updates on views with conditional INSTEAD rules. 2020-01-14 09:50:51 +00:00
snowball Avoid unnecessary use of pg_strcasecmp for already-downcased identifiers. 2018-01-26 18:25:14 -05:00
statistics Make error logging in extended statistics more consistent 2019-05-30 17:06:21 +02:00
storage Free disk space for dropped relations on commit. 2020-12-01 13:46:27 +13:00
tcop Further fixes for CREATE TABLE LIKE: cope with self-referential FKs. 2020-11-19 15:03:17 -05:00
tsearch Avoid possible dangling-pointer access in tsearch_readline_callback. 2020-09-23 11:36:13 -04:00
utils Adjust DSM and DSA slot usage constants (back-patch). 2020-11-20 10:52:38 +13:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
nls.mk Translation updates 2018-09-17 08:40:36 +02:00