Skip to content

Commit bb1d979

Browse files
committed
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.
1 parent c5e38b9 commit bb1d979

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/backend/utils/adt/like.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "catalog/pg_collation.h"
2323
#include "mb/pg_wchar.h"
24+
#include "miscadmin.h"
2425
#include "utils/builtins.h"
2526
#include "utils/pg_locale.h"
2627

src/backend/utils/adt/like_match.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ MatchText(char *t, int tlen, char *p, int plen,
8383
if (plen == 1 && *p == '%')
8484
return LIKE_TRUE;
8585

86+
/* Since this function recurses, it could be driven to stack overflow */
87+
check_stack_depth();
88+
8689
/*
8790
* In this loop, we advance by char when matching wildcards (and thus on
8891
* recursive entry to this function we are properly char-synced). On other

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy