1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-10 09:21:54 +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:
Tom Lane 2018-12-10 11:12:43 -05:00
parent 3a691f8a25
commit 3af726a1f3
3 changed files with 12 additions and 0 deletions

View File

@ -29,6 +29,7 @@
#include "postgres.h"
#include "miscadmin.h"
#include "nodes/relation.h"
#include "utils/datum.h"
@ -2514,6 +2515,9 @@ equal(const void *a, const void *b)
if (nodeTag(a) != nodeTag(b))
return false;
/* Guard against stack overflow due to overly complex expressions */
check_stack_depth();
switch (nodeTag(a))
{
/*

View File

@ -24,6 +24,7 @@
#include <ctype.h>
#include "lib/stringinfo.h"
#include "miscadmin.h"
#include "nodes/plannodes.h"
#include "nodes/relation.h"
#include "utils/datum.h"
@ -2757,6 +2758,9 @@ _outConstraint(StringInfo str, const Constraint *node)
static void
_outNode(StringInfo str, const void *obj)
{
/* Guard against stack overflow due to overly complex expressions */
check_stack_depth();
if (obj == NULL)
appendStringInfoString(str, "<>");
else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))

View File

@ -28,6 +28,7 @@
#include <math.h>
#include "miscadmin.h"
#include "nodes/parsenodes.h"
#include "nodes/readfuncs.h"
@ -1292,6 +1293,9 @@ parseNodeString(void)
READ_TEMP_LOCALS();
/* Guard against stack overflow due to overly complex expressions */
check_stack_depth();
token = pg_strtok(&length);
#define MATCH(tokname, namelen) \