From beca984e5f1c315d02064e69861be112f5a69b3d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 22 Sep 2006 21:39:58 +0000 Subject: Fix bugs in plpgsql and ecpg caused by assuming that isspace() would only return true for exactly the characters treated as whitespace by their flex scanners. Per report from Victor Snezhko and subsequent investigation. Also fix a passel of unsafe usages of functions, that is, ye olde char-vs-unsigned-char issue. I won't miss when we are finally able to stop using it. --- contrib/ltree/crc32.c | 4 ++-- contrib/ltree/ltree_io.c | 10 +++++----- contrib/ltree/ltxtquery_io.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'contrib/ltree') diff --git a/contrib/ltree/crc32.c b/contrib/ltree/crc32.c index c114540181..8f37f47fe2 100644 --- a/contrib/ltree/crc32.c +++ b/contrib/ltree/crc32.c @@ -1,6 +1,6 @@ /* Both POSIX and CRC32 checksums */ -/* $PostgreSQL: pgsql/contrib/ltree/crc32.c,v 1.6 2006/03/11 04:38:29 momjian Exp $ */ +/* $PostgreSQL: pgsql/contrib/ltree/crc32.c,v 1.7 2006/09/22 21:39:57 tgl Exp $ */ #include #include @@ -8,7 +8,7 @@ #ifdef LOWER_NODE #include -#define TOLOWER(x) tolower(x) +#define TOLOWER(x) tolower((unsigned char) (x)) #else #define TOLOWER(x) (x) #endif diff --git a/contrib/ltree/ltree_io.c b/contrib/ltree/ltree_io.c index c147887703..eb22894079 100644 --- a/contrib/ltree/ltree_io.c +++ b/contrib/ltree/ltree_io.c @@ -1,7 +1,7 @@ /* * in/out function for ltree and lquery * Teodor Sigaev - * $PostgreSQL: pgsql/contrib/ltree/ltree_io.c,v 1.12 2006/03/11 04:38:29 momjian Exp $ + * $PostgreSQL: pgsql/contrib/ltree/ltree_io.c,v 1.13 2006/09/22 21:39:57 tgl Exp $ */ #include "ltree.h" @@ -332,7 +332,7 @@ lquery_in(PG_FUNCTION_ARGS) { if (*ptr == ',') state = LQPRS_WAITSNUM; - else if (isdigit((unsigned int) *ptr)) + else if (isdigit((unsigned char) *ptr)) { curqlevel->low = atoi(ptr); state = LQPRS_WAITND; @@ -342,7 +342,7 @@ lquery_in(PG_FUNCTION_ARGS) } else if (state == LQPRS_WAITSNUM) { - if (isdigit((unsigned int) *ptr)) + if (isdigit((unsigned char) *ptr)) { curqlevel->high = atoi(ptr); state = LQPRS_WAITCLOSE; @@ -359,7 +359,7 @@ lquery_in(PG_FUNCTION_ARGS) { if (*ptr == '}') state = LQPRS_WAITEND; - else if (!isdigit((unsigned int) *ptr)) + else if (!isdigit((unsigned char) *ptr)) UNCHAR; } else if (state == LQPRS_WAITND) @@ -371,7 +371,7 @@ lquery_in(PG_FUNCTION_ARGS) } else if (*ptr == ',') state = LQPRS_WAITSNUM; - else if (!isdigit((unsigned int) *ptr)) + else if (!isdigit((unsigned char) *ptr)) UNCHAR; } else if (state == LQPRS_WAITEND) diff --git a/contrib/ltree/ltxtquery_io.c b/contrib/ltree/ltxtquery_io.c index 1142bb3fe3..ca6325adf7 100644 --- a/contrib/ltree/ltxtquery_io.c +++ b/contrib/ltree/ltxtquery_io.c @@ -1,7 +1,7 @@ /* * txtquery io * Teodor Sigaev - * $PostgreSQL: pgsql/contrib/ltree/ltxtquery_io.c,v 1.11 2006/03/11 04:38:29 momjian Exp $ + * $PostgreSQL: pgsql/contrib/ltree/ltxtquery_io.c,v 1.12 2006/09/22 21:39:57 tgl Exp $ */ #include "ltree.h" @@ -81,7 +81,7 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, uint1 *lenval = 1; *flag = 0; } - else if (!isspace((unsigned int) *(state->buf))) + else if (!isspace((unsigned char) *(state->buf))) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("operand syntax error"))); -- cgit v1.2.1