Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit62999b9

Browse files
committed
Add stack depth checks to key recursive functions in backend/nodes/*.c.
Although copyfuncs.c has a check_stack_depth call in its recursion,equalfuncs.c, outfuncs.c, and readfuncs.c lacked one. This seemsunwise.Likewise fix planstate_tree_walker(), in branches where that exists.Discussion:https://postgr.es/m/30253.1544286631@sss.pgh.pa.us
1 parenta628e0c commit62999b9

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

‎src/backend/nodes/equalfuncs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include"postgres.h"
3131

32+
#include"miscadmin.h"
3233
#include"nodes/extensible.h"
3334
#include"nodes/relation.h"
3435
#include"utils/datum.h"
@@ -3001,6 +3002,9 @@ equal(const void *a, const void *b)
30013002
if (nodeTag(a)!=nodeTag(b))
30023003
return false;
30033004

3005+
/* Guard against stack overflow due to overly complex expressions */
3006+
check_stack_depth();
3007+
30043008
switch (nodeTag(a))
30053009
{
30063010
/*

‎src/backend/nodes/nodeFuncs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3726,6 +3726,9 @@ planstate_tree_walker(PlanState *planstate,
37263726
Plan*plan=planstate->plan;
37273727
ListCell*lc;
37283728

3729+
/* Guard against stack overflow due to overly complex plan trees */
3730+
check_stack_depth();
3731+
37293732
/* initPlan-s */
37303733
if (planstate_walk_subplans(planstate->initPlan,walker,context))
37313734
return true;

‎src/backend/nodes/outfuncs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include<ctype.h>
3131

3232
#include"lib/stringinfo.h"
33+
#include"miscadmin.h"
3334
#include"nodes/extensible.h"
3435
#include"nodes/plannodes.h"
3536
#include"nodes/relation.h"
@@ -3703,6 +3704,9 @@ _outPartitionRangeDatum(StringInfo str, const PartitionRangeDatum *node)
37033704
void
37043705
outNode(StringInfostr,constvoid*obj)
37053706
{
3707+
/* Guard against stack overflow due to overly complex expressions */
3708+
check_stack_depth();
3709+
37063710
if (obj==NULL)
37073711
appendStringInfoString(str,"<>");
37083712
elseif (IsA(obj,List)||IsA(obj,IntList)||IsA(obj,OidList))

‎src/backend/nodes/readfuncs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include<math.h>
3030

3131
#include"fmgr.h"
32+
#include"miscadmin.h"
3233
#include"nodes/extensible.h"
3334
#include"nodes/parsenodes.h"
3435
#include"nodes/plannodes.h"
@@ -2539,6 +2540,9 @@ parseNodeString(void)
25392540

25402541
READ_TEMP_LOCALS();
25412542

2543+
/* Guard against stack overflow due to overly complex expressions */
2544+
check_stack_depth();
2545+
25422546
token=pg_strtok(&length);
25432547

25442548
#defineMATCH(tokname,namelen) \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp