From f80af01174fa1aafa97b9464f31db2b554d26f47 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 2 Oct 2015 15:00:52 -0400 Subject: 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. --- src/backend/utils/adt/like_match.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/backend/utils/adt/like_match.c') diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c index 214664116d7..0a650e957d8 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 -- cgit v1.2.3