mirror of
https://github.com/postgres/postgres.git
synced 2025-06-22 02:52:08 +03:00
Fix infinite-loop risk in fixempties() stage of regex compilation.
The previous coding of this function could get into situations where it would never terminate, because successive passes would re-add EMPTY arcs that had been removed by the previous pass. Rewrite the function completely using a new algorithm that is guaranteed to terminate, and also seems to be usually faster than the old one. Per Tcl bugs 3604074 and 3606683. Tom Lane and Don Porter
This commit is contained in:
@ -34,3 +34,10 @@ explain (costs off) select * from pg_proc where proname ~ '^abc+d';
|
||||
explain (costs off) select * from pg_proc where proname ~ '^(abc)(def)';
|
||||
explain (costs off) select * from pg_proc where proname ~ '^(abc)$';
|
||||
explain (costs off) select * from pg_proc where proname ~ '^(abc)?d';
|
||||
|
||||
-- Test for infinite loop in pullback() (CVE-2007-4772)
|
||||
select 'a' ~ '($|^)*';
|
||||
|
||||
-- Test for infinite loop in fixempties() (Tcl bugs 3604074, 3606683)
|
||||
select 'a' ~ '((((((a)*)*)*)*)*)*';
|
||||
select 'a' ~ '((((((a+|)+|)+|)+|)+|)+|)';
|
||||
|
Reference in New Issue
Block a user