aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/like_match.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-10-02 15:00:51 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-10-02 15:00:51 -0400
commit2e8cfcf4ea1140213eae56ce64a2c53182643578 (patch)
treef7b3cd6a9751343c5eba9338624e0240591384ab /src/backend/utils/adt/like_match.c
parentb63fc28776c5d2efdb4de326ad0f0b5b88f82220 (diff)
downloadpostgresql-2e8cfcf4ea1140213eae56ce64a2c53182643578.tar.gz
postgresql-2e8cfcf4ea1140213eae56ce64a2c53182643578.zip
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.
Diffstat (limited to 'src/backend/utils/adt/like_match.c')
-rw-r--r--src/backend/utils/adt/like_match.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c
index 3ec24872d00..83ece28722c 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