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 | 4175cc604f6df6b0f9e9f177898a1b94e6f14aee (patch) | |
tree | b3600a77c3e9f8f71378f6d5e87daadb169754d0 | |
parent | 9ed207ae99bca08851afbc3e189a95468dacdf97 (diff) |
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 605204528e4..5b8c55ebaeb 100644 --- a/src/backend/utils/adt/like.c +++ b/src/backend/utils/adt/like.c @@ -21,6 +21,7 @@ #include "catalog/pg_collation.h" #include "mb/pg_wchar.h" +#include "miscadmin.h" #include "utils/builtins.h" #include "utils/pg_locale.h" diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c index 0c20cd173e5..640f8f2014e 100644 --- a/src/backend/utils/adt/like_match.c +++ b/src/backend/utils/adt/like_match.c @@ -83,6 +83,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 |