aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-10-02 15:00:52 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-10-02 15:00:52 -0400
commitbdc5d95b60bc1f17962a6b6184924b3672bd2f60 (patch)
treecc9c1cf8e4e3a57fcfcac06432d1f1fce51b9b3e /src
parent20c627707c44deaed92c5d67b350f27e06e24228 (diff)
downloadpostgresql-bdc5d95b60bc1f17962a6b6184924b3672bd2f60.tar.gz
postgresql-bdc5d95b60bc1f17962a6b6184924b3672bd2f60.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')
-rw-r--r--src/backend/utils/adt/like.c1
-rw-r--r--src/backend/utils/adt/like_match.c3
2 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c
index 284c5aeb886..b6db4f3b018 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 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