postgresql/src/backend
Tom Lane 9a327179c8 Prevent regexp back-refs from sometimes matching when they shouldn't.
The recursion in cdissect() was careless about clearing match data
for capturing parentheses after rejecting a partial match.  This
could allow a later back-reference to succeed when by rights it
should fail for lack of a defined referent.

To fix, think a little more rigorously about what the contract
between different levels of cdissect's recursion needs to be.
With the right spec, we can fix this using fewer rather than more
resets of the match data; the key decision being that a failed
sub-match is now explicitly responsible for clearing any matches
it may have set.

There are enough other cross-checks and optimizations in the code
that it's not especially easy to exhibit this problem; usually, the
match will fail as-expected.  Plus, regexps that are even potentially
vulnerable are most likely user errors, since there's just not much
point in writing a back-ref that doesn't always have a referent.
These facts perhaps explain why the issue hasn't been detected,
even though it's almost certainly a couple of decades old.

Discussion: https://postgr.es/m/151435.1629733387@sss.pgh.pa.us
2021-08-23 17:41:07 -04:00
..
access Avoid creating archive status ".ready" files too early 2021-08-23 15:50:35 -04:00
bootstrap Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
catalog Prevent ALTER TYPE/DOMAIN/OPERATOR from changing extension membership. 2021-08-17 14:29:22 -04:00
commands Prevent ALTER TYPE/DOMAIN/OPERATOR from changing extension membership. 2021-08-17 14:29:22 -04:00
executor Get rid of artificial restriction on hash table sizes on Windows. 2021-07-25 14:02:27 -04:00
foreign Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jit jit: Don't inline functions that access thread-locals. 2021-07-22 15:07:52 +12:00
lib Fix typo in comment 2021-04-20 14:36:41 +02:00
libpq Set type identifier on BIO 2021-08-17 14:31:00 +02:00
main Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nodes Ensure that expandTableLikeClause() re-examines the same table. 2020-12-01 14:02:27 -05:00
optimizer Get rid of artificial restriction on hash table sizes on Windows. 2021-07-25 14:02:27 -04:00
parser Avoid trying to lock OLD/NEW in a rule with FOR UPDATE. 2021-08-19 12:12:35 -04:00
partitioning Avoid using ambiguous word "non-negative" in error messages. 2021-07-28 01:21:52 +09:00
po Translation updates 2021-08-09 11:56:40 +02:00
port Make EXEC_BACKEND more convenient on macOS. 2021-08-13 11:11:38 +12:00
postmaster Avoid creating archive status ".ready" files too early 2021-08-23 15:50:35 -04:00
regex Prevent regexp back-refs from sometimes matching when they shouldn't. 2021-08-23 17:41:07 -04:00
replication Fix backup manifests to generate correct WAL-Ranges across timelines 2021-08-23 11:09:57 +09:00
rewrite Reject cases where a query in WITH rewrites to just NOTIFY. 2021-07-09 11:02:26 -04:00
snowball Update copyrights for 2020 2020-01-01 12:21:45 -05:00
statistics Use correct spelling of statistics kind 2021-03-23 05:00:19 +01:00
storage Fix check for conflicting session- vs transaction-level locks. 2021-07-24 18:35:52 -04:00
tcop Use elog, not Assert, to report failure to provide an outer snapshot. 2021-07-31 11:50:14 -04:00
tsearch Don't leak compiled regex(es) when an ispell cache entry is dropped. 2021-03-18 21:44:43 -04:00
utils Adjust the integer overflow tests in the numeric code. 2021-08-06 21:31:20 +01: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 Update copyrights for 2020 2020-01-01 12:21:45 -05:00
nls.mk Translation updates 2020-09-14 13:14:53 +02:00