diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2007-09-07 15:35:11 +0000 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2007-09-07 15:35:11 +0000 |
commit | 8983852e343d04696256d576d5009dd7c5e94272 (patch) | |
tree | 40177ca8e59723822f0955f82300e096168263cf /src/backend/utils/adt/tsquery_cleanup.c | |
parent | e5be89981fc70648eedb325781cf2fbd4da05ba8 (diff) | |
download | postgresql-8983852e343d04696256d576d5009dd7c5e94272.tar.gz postgresql-8983852e343d04696256d576d5009dd7c5e94272.zip |
Improving various checks by Heikki Linnakangas <heikki@enterprisedb.com>
- add code to check that the query tree is well-formed. It was indeed
possible to send malformed queries in binary mode, which produced all
kinds of strange results.
- make the left-field a uint32. There's no reason to
arbitrarily limit it to 16-bits, and it won't increase the disk/memory
footprint either now that QueryOperator and QueryOperand are separate
structs.
- add check_stack_depth() call to all recursive functions I found.
Some of them might have a natural limit so that you can't force
arbitrarily deep recursions, but check_stack_depth() is cheap enough
that seems best to just stick it into anything that might be a problem.
Diffstat (limited to 'src/backend/utils/adt/tsquery_cleanup.c')
-rw-r--r-- | src/backend/utils/adt/tsquery_cleanup.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/utils/adt/tsquery_cleanup.c b/src/backend/utils/adt/tsquery_cleanup.c index 22e6f7c8198..6ab58228b59 100644 --- a/src/backend/utils/adt/tsquery_cleanup.c +++ b/src/backend/utils/adt/tsquery_cleanup.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_cleanup.c,v 1.2 2007/09/07 15:09:56 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_cleanup.c,v 1.3 2007/09/07 15:35:10 teodor Exp $ * *------------------------------------------------------------------------- */ @@ -57,6 +57,9 @@ typedef struct static void plainnode(PLAINTREE * state, NODE * node) { + /* since this function recurses, it could be driven to stack overflow. */ + check_stack_depth(); + if (state->cur == state->len) { state->len *= 2; @@ -107,6 +110,9 @@ plaintree(NODE * root, int *len) static void freetree(NODE * node) { + /* since this function recurses, it could be driven to stack overflow. */ + check_stack_depth(); + if (!node) return; if (node->left) @@ -125,6 +131,9 @@ freetree(NODE * node) static NODE * clean_NOT_intree(NODE * node) { + /* since this function recurses, it could be driven to stack overflow. */ + check_stack_depth(); + if (node->valnode->type == QI_VAL) return node; @@ -203,6 +212,9 @@ clean_fakeval_intree(NODE * node, char *result) char lresult = V_UNKNOWN, rresult = V_UNKNOWN; + /* since this function recurses, it could be driven to stack overflow. */ + check_stack_depth(); + if (node->valnode->type == QI_VAL) return node; else |