mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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 <ctype.h> functions, that is, ye olde char-vs-unsigned-char issue. I won't miss <ctype.h> when we are finally able to stop using it.
This commit is contained in:
@ -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 <sys/types.h>
|
||||
#include <stdio.h>
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
#ifdef LOWER_NODE
|
||||
#include <ctype.h>
|
||||
#define TOLOWER(x) tolower(x)
|
||||
#define TOLOWER(x) tolower((unsigned char) (x))
|
||||
#else
|
||||
#define TOLOWER(x) (x)
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* in/out function for ltree and lquery
|
||||
* Teodor Sigaev <teodor@stack.net>
|
||||
* $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)
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* txtquery io
|
||||
* Teodor Sigaev <teodor@stack.net>
|
||||
* $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")));
|
||||
|
Reference in New Issue
Block a user