Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
79048ca1
Commit
79048ca1
authored
Aug 31, 2007
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Install check_stack_depth() protection in two recursive tsquery
processing routines. Per Heikki.
parent
ac20d3df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
src/backend/utils/adt/tsquery.c
src/backend/utils/adt/tsquery.c
+9
-2
src/backend/utils/adt/tsvector_op.c
src/backend/utils/adt/tsvector_op.c
+8
-3
No files found.
src/backend/utils/adt/tsquery.c
View file @
79048ca1
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.
1 2007/08/21 01:11:1
9 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.
2 2007/08/31 02:26:2
9 tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -15,12 +15,14 @@
#include "postgres.h"
#include "libpq/pqformat.h"
#include "miscadmin.h"
#include "tsearch/ts_locale.h"
#include "tsearch/ts_type.h"
#include "tsearch/ts_utils.h"
#include "utils/memutils.h"
#include "utils/pg_crc.h"
/* parser's states */
#define WAITOPERAND 1
#define WAITOPERATOR 2
...
...
@@ -234,11 +236,13 @@ pushval_asis(TSQueryParserState * state, int type, char *strval, int lenval, int
}
#define STACKDEPTH 32
/*
* make polish notation of query
*/
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
,
type
;
...
...
@@ -248,6 +252,9 @@ makepol(TSQueryParserState * state, void (*pushval) (TSQueryParserState *, int,
int4
lenstack
=
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
)
{
switch
(
type
)
...
...
src/backend/utils/adt/tsvector_op.c
View file @
79048ca1
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.
1 2007/08/21 01:11:1
9 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.
2 2007/08/31 02:26:2
9 tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -19,6 +19,7 @@
#include "executor/spi.h"
#include "funcapi.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "tsearch/ts_type.h"
#include "tsearch/ts_utils.h"
#include "utils/builtins.h"
...
...
@@ -525,14 +526,18 @@ checkcondition_str(void *checkval, QueryItem * val)
* check for boolean condition
*/
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
)
return
chkcond
(
checkval
,
curitem
);
else
if
(
curitem
->
val
==
(
int4
)
'!'
)
{
return
(
calcnot
)
?
((
TS_execute
(
curitem
+
1
,
checkval
,
calcnot
,
chkcond
))
?
false
:
true
)
!
TS_execute
(
curitem
+
1
,
checkval
,
calcnot
,
chkcond
)
:
true
;
}
else
if
(
curitem
->
val
==
(
int4
)
'&'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment