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

Commitb0f7dd9

Browse files
committed
Check stack depth in new recursive functions
Commitb0e96f3 introduced a bunch of recursive functions, butfailed to make them check for stack depth. This can cause the backendto crash when operating on inheritance hierarchies several thousandsdeep. Protect the code by adding the missing stack depth checks.Reported-by: Alexander Lakhin <exclusion@gmail.com>Discussion:https://postgr.es/m/b2ac2392-9727-5f76-e890-721ac80c1615@gmail.com
1 parent76db9cb commitb0f7dd9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7630,6 +7630,9 @@ set_attnotnull(List **wqueue, Relation rel, AttrNumber attnum, bool recurse,
76307630
Form_pg_attribute attForm;
76317631
boolretval = false;
76327632

7633+
/* Guard against stack overflow due to overly deep inheritance tree. */
7634+
check_stack_depth();
7635+
76337636
tuple = SearchSysCacheCopyAttNum(RelationGetRelid(rel), attnum);
76347637
if (!HeapTupleIsValid(tuple))
76357638
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
@@ -7716,6 +7719,9 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
77167719
boolis_no_inherit = false;
77177720
List *ready = NIL;
77187721

7722+
/* Guard against stack overflow due to overly deep inheritance tree. */
7723+
check_stack_depth();
7724+
77197725
/*
77207726
* In cases of multiple inheritance, we might visit the same child more
77217727
* than once. In the topmost call, set up a list that we fill with all
@@ -9359,6 +9365,9 @@ ATAddCheckNNConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
93599365
ListCell *child;
93609366
ObjectAddress address = InvalidObjectAddress;
93619367

9368+
/* Guard against stack overflow due to overly deep inheritance tree. */
9369+
check_stack_depth();
9370+
93629371
/* At top level, permission check was done in ATPrepCmd, else do it */
93639372
if (recursing)
93649373
ATSimplePermissions(AT_AddConstraint, rel, ATT_TABLE | ATT_FOREIGN_TABLE);
@@ -12428,6 +12437,9 @@ dropconstraint_internal(Relation rel, HeapTuple constraintTup, DropBehavior beha
1242812437
return InvalidObjectAddress;
1242912438
*readyRels = lappend_oid(*readyRels, RelationGetRelid(rel));
1243012439

12440+
/* Guard against stack overflow due to overly deep inheritance tree. */
12441+
check_stack_depth();
12442+
1243112443
/* At top level, permission check was done in ATPrepCmd, else do it */
1243212444
if (recursing)
1243312445
ATSimplePermissions(AT_DropConstraint, rel, ATT_TABLE | ATT_FOREIGN_TABLE);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp