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

Commit0398e07

Browse files
committed
Prevent stack overflow in container-type functions.
A range type can name another range type as its subtype, and a recordtype can bear a column of another record type. Consequently, functionslike range_cmp() and record_recv() are recursive. Functions at riskinclude operator family members and referents of pg_type regproccolumns. Treat as recursive any such function that looks up and callsthe same-purpose function for a record column type or the range subtype.Back-patch to 9.0 (all supported versions).An array type's element type is never itself an array type, so arrayfunctions are unaffected. Recursion depth proportional to arraydimensionality, found in array_dim_to_jsonb(), is fine thanks to MAXDIM.
1 parent188e081 commit0398e07

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include"catalog/pg_type.h"
2020
#include"funcapi.h"
2121
#include"libpq/pqformat.h"
22+
#include"miscadmin.h"
2223
#include"utils/builtins.h"
2324
#include"utils/lsyscache.h"
2425
#include"utils/typcache.h"
@@ -88,6 +89,8 @@ record_in(PG_FUNCTION_ARGS)
8889
bool*nulls;
8990
StringInfoDatabuf;
9091

92+
check_stack_depth();/* recurses for record-type columns */
93+
9194
/*
9295
* Use the passed type unless it's RECORD; we can't support input of
9396
* anonymous types, mainly because there's no good way to figure out which
@@ -310,6 +313,8 @@ record_out(PG_FUNCTION_ARGS)
310313
bool*nulls;
311314
StringInfoDatabuf;
312315

316+
check_stack_depth();/* recurses for record-type columns */
317+
313318
/* Extract type info from the tuple itself */
314319
tupType=HeapTupleHeaderGetTypeId(rec);
315320
tupTypmod=HeapTupleHeaderGetTypMod(rec);
@@ -477,6 +482,8 @@ record_recv(PG_FUNCTION_ARGS)
477482
Datum*values;
478483
bool*nulls;
479484

485+
check_stack_depth();/* recurses for record-type columns */
486+
480487
/*
481488
* Use the passed type unless it's RECORD; we can't support input of
482489
* anonymous types, mainly because there's no good way to figure out which
@@ -667,6 +674,8 @@ record_send(PG_FUNCTION_ARGS)
667674
bool*nulls;
668675
StringInfoDatabuf;
669676

677+
check_stack_depth();/* recurses for record-type columns */
678+
670679
/* Extract type info from the tuple itself */
671680
tupType=HeapTupleHeaderGetTypeId(rec);
672681
tupTypmod=HeapTupleHeaderGetTypMod(rec);
@@ -826,6 +835,8 @@ record_cmp(FunctionCallInfo fcinfo)
826835
inti2;
827836
intj;
828837

838+
check_stack_depth();/* recurses for record-type columns */
839+
829840
/* Extract type info from the tuples */
830841
tupType1=HeapTupleHeaderGetTypeId(record1);
831842
tupTypmod1=HeapTupleHeaderGetTypMod(record1);
@@ -1052,6 +1063,8 @@ record_eq(PG_FUNCTION_ARGS)
10521063
inti2;
10531064
intj;
10541065

1066+
check_stack_depth();/* recurses for record-type columns */
1067+
10551068
/* Extract type info from the tuples */
10561069
tupType1=HeapTupleHeaderGetTypeId(record1);
10571070
tupTypmod1=HeapTupleHeaderGetTypMod(record1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp