summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane2022-08-13 19:21:28 +0000
committerTom Lane2022-08-13 19:21:28 +0000
commit362032f1768e0c0792fb713234ea1db2ebfaf90d (patch)
treed9a731f8c43f23f19b8beae568027bce2b240043 /src
parent5dfb9583101069e87a784db47fd99ada8ac8d6b7 (diff)
Catch stack overflow when recursing in transformFromClauseItem().
Most parts of the parser can expect that the stack overflow check in transformExprRecurse() will trigger before things get desperate. However, transformFromClauseItem() can recurse directly to self without having analyzed any expressions, so it's possible to drive it to a stack-overrun crash. Add a check to prevent that. Per bug #17583 from Egor Chindyaskin. Back-patch to all supported branches. Richard Guo Discussion: https://postgr.es/m/17583-33be55b9f981f75c@postgresql.org
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/parse_clause.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index 8ebee4fa5f3..6322deeb122 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -1099,6 +1099,9 @@ transformFromClauseItem(ParseState *pstate, Node *n,
RangeTblEntry **top_rte, int *top_rti,
List **namespace)
{
+ /* Guard against stack overflow due to overly deep subtree */
+ check_stack_depth();
+
if (IsA(n, RangeVar))
{
/* Plain relation reference, or perhaps a CTE reference */