postgresql/src/backend
Tom Lane 62ee703313 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 Avoid using tuple from syscache for update of pg_database.datfrozenxid 2020-12-08 12:13:19 +09:00
bootstrap Fix some stray whitespace in parser files 2020-11-11 17:37:18 +01:00
catalog Track total number of WAL records, FPIs and bytes generated in the cluster. 2020-12-02 13:00:15 +09:00
commands Avoid using tuple from syscache for update of pg_database.datfrozenxid 2020-12-08 12:13:19 +09:00
executor Remove catalog function currtid() 2020-11-25 12:18:26 +09:00
foreign Small code simplifications 2020-12-03 11:44:13 +01:00
jit jit: Correct parameter type for generated expression evaluation functions. 2020-12-07 19:34:13 -08:00
lib Use pg_bitutils for HyperLogLog. 2020-07-30 09:14:23 -07:00
libpq Convert elog(LOG) calls to ereport() where appropriate 2020-12-04 14:25:23 +01:00
main Remove -o option to postmaster 2020-11-10 13:15:01 +01:00
nodes Remove operator_precedence_warning. 2020-12-08 16:29:52 -05:00
optimizer Teach contain_leaked_vars that assignment SubscriptingRefs are leaky. 2020-12-08 17:50:54 -05:00
parser Remove operator_precedence_warning. 2020-12-08 16:29:52 -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-05-18 12:49:30 +02:00
port Fix -Wcast-function-type warnings on Windows/MinGW 2020-10-21 08:17:51 +02:00
postmaster Speed up rechecking if relation needs to be vacuumed or analyze in autovacuum. 2020-12-08 23:59:39 +09:00
regex Dial back -Wimplicit-fallthrough to level 3 2020-05-13 15:31:14 -04:00
replication Convert elog(LOG) calls to ereport() where appropriate 2020-12-04 14:25:23 +01:00
rewrite Improve wording of two error messages related to generated columns. 2020-11-23 11:15:12 -05:00
snowball code: replace most remaining uses of 'master'. 2020-07-08 13:24:35 -07:00
statistics Improve estimation of ANDs under ORs using extended statistics. 2020-12-08 20:10:11 +00:00
storage Convert elog(LOG) calls to ereport() where appropriate 2020-12-04 14:25:23 +01:00
tcop Refactor CLUSTER and REINDEX grammar to use DefElem for option lists 2020-12-03 10:13:21 +09:00
tsearch Improve behavior of tsearch_readline(), and remove t_readline(). 2020-09-23 20:26:58 -04:00
utils Remove operator_precedence_warning. 2020-12-08 16:29:52 -05:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Add missing gettext triggers 2020-04-28 13:35:40 +02:00