aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Gustafsson <dgustafsson@postgresql.org>2023-11-30 10:56:48 +0100
committerDaniel Gustafsson <dgustafsson@postgresql.org>2023-11-30 10:56:48 +0100
commit17935e1fdf0aff083347b4b2d6268d945041d188 (patch)
tree0207b3b86451f642c3a27c1b8a45070a790242d7 /src
parentb589f211e025eb66f7c9e5a0b0cc23cc6fff3605 (diff)
downloadpostgresql-17935e1fdf0aff083347b4b2d6268d945041d188.tar.gz
postgresql-17935e1fdf0aff083347b4b2d6268d945041d188.zip
Fix array subscript warnings
Commit a5cf808be55 accidentally passed signed chars to isalpha and isspace in the parser code which leads to undefined behavior. Fix by casting the parameters to unsigned chars. Author: Pavel Stehule <pavel.stehule@gmail.com> Reported-by: Tom Lane <tgl@sss.pgh.pa.us> Reported-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/388186.1701315586@sss.pgh.pa.us Discussion: https://postgr.es/m/ZWgg5xim2CXQcfmh@paquier.xyz
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/filter.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/bin/pg_dump/filter.c b/src/bin/pg_dump/filter.c
index dff871c7cd0..d79b6da27c0 100644
--- a/src/bin/pg_dump/filter.c
+++ b/src/bin/pg_dump/filter.c
@@ -185,14 +185,14 @@ filter_get_keyword(const char **line, int *size)
*size = 0;
/* Skip initial whitespace */
- while (isspace(*ptr))
+ while (isspace((unsigned char) *ptr))
ptr++;
- if (isalpha(*ptr))
+ if (isalpha((unsigned char) *ptr))
{
result = ptr++;
- while (isalpha(*ptr) || *ptr == '_')
+ while (isalpha((unsigned char) *ptr) || *ptr == '_')
ptr++;
*size = ptr - result;
@@ -301,7 +301,7 @@ read_pattern(FilterStateData *fstate, const char *str, PQExpBuffer pattern)
bool found_space = false;
/* Skip initial whitespace */
- while (isspace(*str))
+ while (isspace((unsigned char) *str))
str++;
if (*str == '\0')
@@ -312,7 +312,7 @@ read_pattern(FilterStateData *fstate, const char *str, PQExpBuffer pattern)
while (*str && *str != '#')
{
- while (*str && !isspace(*str) && !strchr("#,.()\"", *str))
+ while (*str && !isspace((unsigned char) *str) && !strchr("#,.()\"", *str))
{
/*
* Append space only when it is allowed, and when it was found in
@@ -351,7 +351,7 @@ read_pattern(FilterStateData *fstate, const char *str, PQExpBuffer pattern)
found_space = false;
/* skip ending whitespaces */
- while (isspace(*str))
+ while (isspace((unsigned char) *str))
{
found_space = true;
str++;
@@ -400,7 +400,7 @@ filter_read_item(FilterStateData *fstate,
fstate->lineno++;
/* Skip initial white spaces */
- while (isspace(*str))
+ while (isspace((unsigned char) *str))
str++;
/*