mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
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 seems unwise. Likewise fix planstate_tree_walker(), in branches where that exists. Discussion: https://postgr.es/m/30253.1544286631@sss.pgh.pa.us
This commit is contained in:
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
|
#include "miscadmin.h"
|
||||||
#include "nodes/extensible.h"
|
#include "nodes/extensible.h"
|
||||||
#include "nodes/relation.h"
|
#include "nodes/relation.h"
|
||||||
#include "utils/datum.h"
|
#include "utils/datum.h"
|
||||||
@ -2978,6 +2979,9 @@ equal(const void *a, const void *b)
|
|||||||
if (nodeTag(a) != nodeTag(b))
|
if (nodeTag(a) != nodeTag(b))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/* Guard against stack overflow due to overly complex expressions */
|
||||||
|
check_stack_depth();
|
||||||
|
|
||||||
switch (nodeTag(a))
|
switch (nodeTag(a))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -3701,6 +3701,9 @@ planstate_tree_walker(PlanState *planstate,
|
|||||||
Plan *plan = planstate->plan;
|
Plan *plan = planstate->plan;
|
||||||
ListCell *lc;
|
ListCell *lc;
|
||||||
|
|
||||||
|
/* Guard against stack overflow due to overly complex plan trees */
|
||||||
|
check_stack_depth();
|
||||||
|
|
||||||
/* initPlan-s */
|
/* initPlan-s */
|
||||||
if (planstate_walk_subplans(planstate->initPlan, walker, context))
|
if (planstate_walk_subplans(planstate->initPlan, walker, context))
|
||||||
return true;
|
return true;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
|
#include "miscadmin.h"
|
||||||
#include "nodes/extensible.h"
|
#include "nodes/extensible.h"
|
||||||
#include "nodes/plannodes.h"
|
#include "nodes/plannodes.h"
|
||||||
#include "nodes/relation.h"
|
#include "nodes/relation.h"
|
||||||
@ -3615,6 +3616,9 @@ _outPartitionRangeDatum(StringInfo str, const PartitionRangeDatum *node)
|
|||||||
void
|
void
|
||||||
outNode(StringInfo str, const void *obj)
|
outNode(StringInfo str, const void *obj)
|
||||||
{
|
{
|
||||||
|
/* Guard against stack overflow due to overly complex expressions */
|
||||||
|
check_stack_depth();
|
||||||
|
|
||||||
if (obj == NULL)
|
if (obj == NULL)
|
||||||
appendStringInfoString(str, "<>");
|
appendStringInfoString(str, "<>");
|
||||||
else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
|
else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "fmgr.h"
|
#include "fmgr.h"
|
||||||
|
#include "miscadmin.h"
|
||||||
#include "nodes/extensible.h"
|
#include "nodes/extensible.h"
|
||||||
#include "nodes/parsenodes.h"
|
#include "nodes/parsenodes.h"
|
||||||
#include "nodes/plannodes.h"
|
#include "nodes/plannodes.h"
|
||||||
@ -2452,6 +2453,9 @@ parseNodeString(void)
|
|||||||
|
|
||||||
READ_TEMP_LOCALS();
|
READ_TEMP_LOCALS();
|
||||||
|
|
||||||
|
/* Guard against stack overflow due to overly complex expressions */
|
||||||
|
check_stack_depth();
|
||||||
|
|
||||||
token = pg_strtok(&length);
|
token = pg_strtok(&length);
|
||||||
|
|
||||||
#define MATCH(tokname, namelen) \
|
#define MATCH(tokname, namelen) \
|
||||||
|
Reference in New Issue
Block a user