postgresql/src
Tom Lane 779557bd22 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
..
backend Prevent regexp back-refs from sometimes matching when they shouldn't. 2021-08-23 17:41:07 -04:00
bin Fix backup manifests to generate correct WAL-Ranges across timelines 2021-08-23 11:09:54 +09:00
common Revert refactoring of hex code to src/common/ 2021-08-19 09:20:19 +09:00
fe_utils Fix incautious handling of possibly-miscoded strings in client code. 2021-06-07 14:15:25 -04:00
include Avoid creating archive status ".ready" files too early 2021-08-23 15:50:35 -04:00
interfaces Improved ECPG warning as suggested by Michael Paquier and removed test case 2021-08-17 15:00:42 +02:00
makefiles Add NO_INSTALL option to pgxs 2021-05-27 13:58:29 +02:00
pl Improve error messages about misuse of SELECT INTO. 2021-08-21 10:22:14 -04:00
port Make printf("%s", NULL) print "(null)" instead of crashing. 2021-07-24 13:41:17 -04:00
template Further tweaking of PG_SYSROOT heuristics for macOS. 2021-01-20 12:07:23 -05:00
test Prevent regexp back-refs from sometimes matching when they shouldn't. 2021-08-23 17:41:07 -04:00
timezone Update time zone data files to tzdata release 2021a. 2021-01-24 16:29:47 -05:00
tools Revert refactoring of hex code to src/common/ 2021-08-19 09:20:19 +09:00
tutorial doc: Prefer explicit JOIN syntax over old implicit syntax in tutorial 2021-04-08 10:51:26 +02: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 Fix prove_installcheck to use correct paths when used with PGXS 2021-07-01 08:46:21 -04:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk Add errhint_plural() function and make use of it 2021-03-31 09:16:25 +02:00