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

Commitd57b7cc

Browse files
committed
Add missing check_stack_depth() to some recursive functions
Reported-by: Egor Chindyaskin, Alexander LakhinDiscussion:https://postgr.es/m/1672760457.940462079%40f306.i.mail.ru
1 parenteb49e1b commitd57b7cc

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

‎src/backend/catalog/dependency.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#include"commands/trigger.h"
7777
#include"commands/typecmds.h"
7878
#include"funcapi.h"
79+
#include"miscadmin.h"
7980
#include"nodes/nodeFuncs.h"
8081
#include"parser/parsetree.h"
8182
#include"rewrite/rewriteRemove.h"
@@ -524,6 +525,12 @@ findDependentObjects(const ObjectAddress *object,
524525
if (stack_address_present_add_flags(object,objflags,stack))
525526
return;
526527

528+
/*
529+
* since this function recurses, it could be driven to stack overflow,
530+
* because of the deep dependency tree, not only due to dependency loops.
531+
*/
532+
check_stack_depth();
533+
527534
/*
528535
* It's also possible that the target object has already been completely
529536
* processed and put into targetObjects. If so, again we just add the

‎src/backend/catalog/heap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,9 @@ CheckAttributeType(const char *attname,
552552
charatt_typtype=get_typtype(atttypid);
553553
Oidatt_typelem;
554554

555+
/* since this function recurses, it could be driven to stack overflow */
556+
check_stack_depth();
557+
555558
if (att_typtype==TYPTYPE_PSEUDO)
556559
{
557560
/*

‎src/backend/commands/tablecmds.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7035,6 +7035,9 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
70357035
ObjectAddress address;
70367036
TupleDesctupdesc;
70377037

7038+
/* since this function recurses, it could be driven to stack overflow */
7039+
check_stack_depth();
7040+
70387041
/* At top level, permission check was done in ATPrepCmd, else do it */
70397042
if (recursing)
70407043
ATSimplePermissions((*cmd)->subtype, rel, ATT_TABLE | ATT_FOREIGN_TABLE);
@@ -9083,6 +9086,10 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
90839086

90849087
/* Initialize addrs on the first invocation */
90859088
Assert(!recursing || addrs != NULL);
9089+
9090+
/* since this function recurses, it could be driven to stack overflow */
9091+
check_stack_depth();
9092+
90869093
if (!recursing)
90879094
addrs = new_object_addresses();
90889095

@@ -11636,6 +11643,9 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel,
1163611643
Oidrefrelid;
1163711644
boolchanged = false;
1163811645

11646+
/* since this function recurses, it could be driven to stack overflow */
11647+
check_stack_depth();
11648+
1163911649
currcon = (Form_pg_constraint) GETSTRUCT(contuple);
1164011650
conoid = currcon->oid;
1164111651
refrelid = currcon->confrelid;
@@ -12716,6 +12726,9 @@ dropconstraint_internal(Relation rel, HeapTuple constraintTup, DropBehavior beha
1271612726
/* Guard against stack overflow due to overly deep inheritance tree. */
1271712727
check_stack_depth();
1271812728

12729+
/* since this function recurses, it could be driven to stack overflow */
12730+
check_stack_depth();
12731+
1271912732
/* At top level, permission check was done in ATPrepCmd, else do it */
1272012733
if (recursing)
1272112734
ATSimplePermissions(AT_DropConstraint, rel, ATT_TABLE | ATT_FOREIGN_TABLE);

‎src/backend/optimizer/util/clauses.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,6 +2423,10 @@ static Node *
24232423
eval_const_expressions_mutator(Node*node,
24242424
eval_const_expressions_context*context)
24252425
{
2426+
2427+
/* since this function recurses, it could be driven to stack overflow */
2428+
check_stack_depth();
2429+
24262430
if (node==NULL)
24272431
returnNULL;
24282432
switch (nodeTag(node))

‎src/backend/utils/adt/jsonpath_exec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,9 @@ executeBoolItem(JsonPathExecContext *cxt, JsonPathItem *jsp,
16741674
JsonPathBoolres;
16751675
JsonPathBoolres2;
16761676

1677+
/* since this function recurses, it could be driven to stack overflow */
1678+
check_stack_depth();
1679+
16771680
if (!canHaveNext&&jspHasNext(jsp))
16781681
elog(ERROR,"boolean jsonpath item cannot have next item");
16791682

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp