diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-10-02 15:00:52 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-10-02 15:00:52 -0400 |
commit | b875ca09f3626e4002b5e70e00f99e4bc29c4d32 (patch) | |
tree | b72b4bd84476d56a95702cb46b951b37e011521b | |
parent | 54b116d83f828f5cff2e867d8a067c204d0978ab (diff) | |
download | postgresql-b875ca09f3626e4002b5e70e00f99e4bc29c4d32.tar.gz |
Add recursion depth protection to LIKE matching.
Since MatchText() recurses, it could in principle be driven to stack
overflow, although quite a long pattern would be needed.
-rw-r--r-- | src/backend/utils/adt/like.c | 1 | ||||
-rw-r--r-- | src/backend/utils/adt/like_match.c | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c index b338f451c3..84e74e8457 100644 --- a/src/backend/utils/adt/like.c +++ b/src/backend/utils/adt/like.c @@ -20,6 +20,7 @@ #include <ctype.h> #include "mb/pg_wchar.h" +#include "miscadmin.h" #include "utils/builtins.h" diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c index 4f762b85c3..0af0ddcf49 100644 --- a/src/backend/utils/adt/like_match.c +++ b/src/backend/utils/adt/like_match.c @@ -82,6 +82,9 @@ MatchText(char *t, int tlen, char *p, int plen) if (plen == 1 && *p == '%') return LIKE_TRUE; + /* Since this function recurses, it could be driven to stack overflow */ + check_stack_depth(); + /* * In this loop, we advance by char when matching wildcards (and thus on * recursive entry to this function we are properly char-synced). On other |