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.
This commit is contained in:
Tom Lane 2015-10-02 15:00:52 -04:00
parent 54b116d83f
commit b875ca09f3
2 changed files with 4 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include <ctype.h>
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "utils/builtins.h"

View File

@ -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