Skip to content
Snippets Groups Projects
Commit 2e8cfcf4 authored by Tom Lane's avatar Tom Lane
Browse files

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.
parent b63fc287
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "catalog/pg_collation.h" #include "catalog/pg_collation.h"
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/pg_locale.h" #include "utils/pg_locale.h"
......
...@@ -83,6 +83,9 @@ MatchText(char *t, int tlen, char *p, int plen, ...@@ -83,6 +83,9 @@ MatchText(char *t, int tlen, char *p, int plen,
if (plen == 1 && *p == '%') if (plen == 1 && *p == '%')
return LIKE_TRUE; 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 * 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 * recursive entry to this function we are properly char-synced). On other
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment