pgsql: Add recursion depth protections to regular expression matching.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Add recursion depth protections to regular expression matching.
Дата
Msg-id E1Zi5RP-0000vg-1o@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Add recursion depth protections to regular expression matching.

Some of the functions in regex compilation and execution recurse, and
therefore could in principle be driven to stack overflow.  The Tcl crew
has seen this happen in practice in duptraverse(), though their fix was
to put in a hard-wired limit on the number of recursive levels, which is
not too appetizing --- fortunately, we have enough infrastructure to check
the actually available stack.  Greg Stark has also seen it in other places
while fuzz testing on a machine with limited stack space.  Let's put guards
in to prevent crashes in all these places.

Since the regex code would leak memory if we simply threw elog(ERROR),
we have to introduce an API that checks for stack depth without throwing
such an error.  Fortunately that's not difficult.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/9ed207ae99bca08851afbc3e189a95468dacdf97

Modified Files
--------------
src/backend/regex/regc_nfa.c |   68 +++++++++++++++++++++++++++++++++++++-----
src/backend/regex/regcomp.c  |   34 +++++++++++++++++++--
src/backend/regex/rege_dfa.c |    7 +++++
src/backend/regex/regexec.c  |    3 ++
src/backend/tcop/postgres.c  |   39 +++++++++++++-----------
src/include/miscadmin.h      |    1 +
src/include/regex/regguts.h  |    4 +++
7 files changed, 129 insertions(+), 27 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Add recursion depth protections to regular expression matching.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Add recursion depth protections to regular expression matching.