1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-22 02:52:08 +03:00

Install check_stack_depth() protection in two recursive tsquery

processing routines.  Per Heikki.
This commit is contained in:
Tom Lane
2007-08-31 02:26:29 +00:00
parent ac20d3dfbe
commit 79048ca1a4
2 changed files with 17 additions and 5 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.1 2007/08/21 01:11:19 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.2 2007/08/31 02:26:29 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)