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

Commit682a25d

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 parent0398e07 commit682a25d

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
@@ -541,6 +541,9 @@ typedef struct
541541
staticvoid
542542
infix(INFIX*in,boolfirst)
543543
{
544+
/* since this function recurses, it could be driven to stack overflow. */
545+
check_stack_depth();
546+
544547
if (in->curpol->type==VAL)
545548
{
546549
RESIZEBUF(in,11);

‎contrib/ltree/ltxtquery_io.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) \
420420
staticvoid
421421
infix(INFIX*in,boolfirst)
422422
{
423+
/* since this function recurses, it could be driven to stack overflow. */
424+
check_stack_depth();
425+
423426
if (in->curpol->type==VAL)
424427
{
425428
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== (int4)'!')

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

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp