Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
79048ca1
Commit
79048ca1
authored
17 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Install check_stack_depth() protection in two recursive tsquery
processing routines. Per Heikki.
parent
ac20d3df
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/backend/utils/adt/tsquery.c
+9
-2
9 additions, 2 deletions
src/backend/utils/adt/tsquery.c
src/backend/utils/adt/tsvector_op.c
+8
-3
8 additions, 3 deletions
src/backend/utils/adt/tsvector_op.c
with
17 additions
and
5 deletions
src/backend/utils/adt/tsquery.c
+
9
−
2
View file @
79048ca1
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.
1
2007/08/
2
1 0
1:11:1
9 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.
2
2007/08/
3
1 0
2:26:2
9 tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -15,12 +15,14 @@
...
@@ -15,12 +15,14 @@
#include
"postgres.h"
#include
"postgres.h"
#include
"libpq/pqformat.h"
#include
"libpq/pqformat.h"
#include
"miscadmin.h"
#include
"tsearch/ts_locale.h"
#include
"tsearch/ts_locale.h"
#include
"tsearch/ts_type.h"
#include
"tsearch/ts_type.h"
#include
"tsearch/ts_utils.h"
#include
"tsearch/ts_utils.h"
#include
"utils/memutils.h"
#include
"utils/memutils.h"
#include
"utils/pg_crc.h"
#include
"utils/pg_crc.h"
/* parser's states */
/* parser's states */
#define WAITOPERAND 1
#define WAITOPERAND 1
#define WAITOPERATOR 2
#define WAITOPERATOR 2
...
@@ -234,11 +236,13 @@ pushval_asis(TSQueryParserState * state, int type, char *strval, int lenval, int
...
@@ -234,11 +236,13 @@ pushval_asis(TSQueryParserState * state, int type, char *strval, int lenval, int
}
}
#define STACKDEPTH 32
#define STACKDEPTH 32
/*
/*
* make polish notation of query
* make polish notation of query
*/
*/
static
int4
static
int4
makepol
(
TSQueryParserState
*
state
,
void
(
*
pushval
)
(
TSQueryParserState
*
,
int
,
char
*
,
int
,
int2
))
makepol
(
TSQueryParserState
*
state
,
void
(
*
pushval
)
(
TSQueryParserState
*
,
int
,
char
*
,
int
,
int2
))
{
{
int4
val
=
0
,
int4
val
=
0
,
type
;
type
;
...
@@ -248,6 +252,9 @@ makepol(TSQueryParserState * state, void (*pushval) (TSQueryParserState *, int,
...
@@ -248,6 +252,9 @@ makepol(TSQueryParserState * state, void (*pushval) (TSQueryParserState *, int,
int4
lenstack
=
0
;
int4
lenstack
=
0
;
int2
weight
=
0
;
int2
weight
=
0
;
/* since this function recurses, it could be driven to stack overflow */
check_stack_depth
();
while
((
type
=
gettoken_query
(
state
,
&
val
,
&
lenval
,
&
strval
,
&
weight
))
!=
END
)
while
((
type
=
gettoken_query
(
state
,
&
val
,
&
lenval
,
&
strval
,
&
weight
))
!=
END
)
{
{
switch
(
type
)
switch
(
type
)
...
...
This diff is collapsed.
Click to expand it.
src/backend/utils/adt/tsvector_op.c
+
8
−
3
View file @
79048ca1
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.
1
2007/08/
2
1 0
1:11:1
9 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.
2
2007/08/
3
1 0
2:26:2
9 tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include
"executor/spi.h"
#include
"executor/spi.h"
#include
"funcapi.h"
#include
"funcapi.h"
#include
"mb/pg_wchar.h"
#include
"mb/pg_wchar.h"
#include
"miscadmin.h"
#include
"tsearch/ts_type.h"
#include
"tsearch/ts_type.h"
#include
"tsearch/ts_utils.h"
#include
"tsearch/ts_utils.h"
#include
"utils/builtins.h"
#include
"utils/builtins.h"
...
@@ -525,14 +526,18 @@ checkcondition_str(void *checkval, QueryItem * val)
...
@@ -525,14 +526,18 @@ checkcondition_str(void *checkval, QueryItem * val)
* check for boolean condition
* check for boolean condition
*/
*/
bool
bool
TS_execute
(
QueryItem
*
curitem
,
void
*
checkval
,
bool
calcnot
,
bool
(
*
chkcond
)
(
void
*
checkval
,
QueryItem
*
val
))
TS_execute
(
QueryItem
*
curitem
,
void
*
checkval
,
bool
calcnot
,
bool
(
*
chkcond
)
(
void
*
checkval
,
QueryItem
*
val
))
{
{
/* since this function recurses, it could be driven to stack overflow */
check_stack_depth
();
if
(
curitem
->
type
==
VAL
)
if
(
curitem
->
type
==
VAL
)
return
chkcond
(
checkval
,
curitem
);
return
chkcond
(
checkval
,
curitem
);
else
if
(
curitem
->
val
==
(
int4
)
'!'
)
else
if
(
curitem
->
val
==
(
int4
)
'!'
)
{
{
return
(
calcnot
)
?
return
(
calcnot
)
?
((
TS_execute
(
curitem
+
1
,
checkval
,
calcnot
,
chkcond
)
)
?
false
:
true
)
!
TS_execute
(
curitem
+
1
,
checkval
,
calcnot
,
chkcond
)
:
true
;
:
true
;
}
}
else
if
(
curitem
->
val
==
(
int4
)
'&'
)
else
if
(
curitem
->
val
==
(
int4
)
'&'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment