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

Commit5976097

Browse files
committed
Prevent stack overflow in query-type functions.
The tsquery, ltxtquery and query_int data types have a common ancestor.Having acquired check_stack_depth() calls independently, each wasmissing at least one call. Back-patch to 9.0 (all supported versions).
1 parent30cb128 commit5976097

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

‎contrib/intarray/_int_bool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,9 @@ typedef struct
564564
staticvoid
565565
infix(INFIX*in,boolfirst)
566566
{
567+
/* since this function recurses, it could be driven to stack overflow. */
568+
check_stack_depth();
569+
567570
if (in->curpol->type==VAL)
568571
{
569572
RESIZEBUF(in,11);

‎contrib/ltree/ltxtquery_io.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) \
416416
staticvoid
417417
infix(INFIX*in,boolfirst)
418418
{
419+
/* since this function recurses, it could be driven to stack overflow. */
420+
check_stack_depth();
421+
419422
if (in->curpol->type==VAL)
420423
{
421424
char*op=in->op+in->curpol->distance;

‎contrib/ltree/ltxtquery_op.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include<ctype.h>
99

1010
#include"ltree.h"
11+
#include"miscadmin.h"
1112

1213
PG_FUNCTION_INFO_V1(ltxtq_exec);
1314
PG_FUNCTION_INFO_V1(ltxtq_rexec);
@@ -18,6 +19,9 @@ PG_FUNCTION_INFO_V1(ltxtq_rexec);
1819
bool
1920
ltree_execute(ITEM*curitem,void*checkval,boolcalcnot,bool (*chkcond) (void*checkval,ITEM*val))
2021
{
22+
/* since this function recurses, it could be driven to stack overflow */
23+
check_stack_depth();
24+
2125
if (curitem->type==VAL)
2226
return (*chkcond) (checkval,curitem);
2327
elseif (curitem->val== (int32)'!')

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ maketree(QueryItem *in)
3333
{
3434
NODE*node= (NODE*)palloc(sizeof(NODE));
3535

36+
/* since this function recurses, it could be driven to stack overflow. */
37+
check_stack_depth();
38+
3639
node->valnode=in;
3740
node->right=node->left=NULL;
3841
if (in->type==QI_OPR)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp