postgresql/src
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
..
backend Teach contain_leaked_vars that assignment SubscriptingRefs are leaky. 2020-12-08 17:50:54 -05:00
bin Fix more race conditions in the newly-added pg_rewind test. 2020-12-07 14:50:20 +02:00
common Change SHA2 implementation based on OpenSSL to use EVP digest routines 2020-12-04 10:49:23 +09:00
fe_utils Remove incorrect %s in string 2020-11-09 10:38:22 +01:00
include Remove operator_precedence_warning. 2020-12-08 16:29:52 -05:00
interfaces Move SHA2 routines to a new generic API layer for crypto hashes 2020-12-02 10:37:20 +09:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Don't use custom OID symbols in pg_type.dat, either. 2020-10-29 13:33:38 -04:00
port Remove ability to independently select random number generator 2020-11-20 13:57:33 +01:00
template On macOS, use -isysroot in link steps as well as compile steps. 2020-11-20 00:07:09 -05:00
test Improve estimation of ANDs under ORs using extended statistics. 2020-12-08 20:10:11 +00:00
timezone Update time zone data files to tzdata release 2020d. 2020-10-22 21:23:47 -04:00
tools Change SHA2 implementation based on OpenSSL to use EVP digest routines 2020-12-04 10:49:23 +09:00
tutorial Remove support for postfix (right-unary) operators. 2020-09-17 19:38:05 -04:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Split Makefile symbol CFLAGS_VECTOR into two symbols. 2020-09-06 21:28:16 -04:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00