Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 17935e1

Browse files
Fix array subscript warnings
Commit a5cf808 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
1 parent b589f21 commit 17935e1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/bin/pg_dump/filter.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ filter_get_keyword(const char **line, int *size)
185185
*size = 0;
186186

187187
/* Skip initial whitespace */
188-
while (isspace(*ptr))
188+
while (isspace((unsigned char) *ptr))
189189
ptr++;
190190

191-
if (isalpha(*ptr))
191+
if (isalpha((unsigned char) *ptr))
192192
{
193193
result = ptr++;
194194

195-
while (isalpha(*ptr) || *ptr == '_')
195+
while (isalpha((unsigned char) *ptr) || *ptr == '_')
196196
ptr++;
197197

198198
*size = ptr - result;
@@ -301,7 +301,7 @@ read_pattern(FilterStateData *fstate, const char *str, PQExpBuffer pattern)
301301
bool found_space = false;
302302

303303
/* Skip initial whitespace */
304-
while (isspace(*str))
304+
while (isspace((unsigned char) *str))
305305
str++;
306306

307307
if (*str == '\0')
@@ -312,7 +312,7 @@ read_pattern(FilterStateData *fstate, const char *str, PQExpBuffer pattern)
312312

313313
while (*str && *str != '#')
314314
{
315-
while (*str && !isspace(*str) && !strchr("#,.()\"", *str))
315+
while (*str && !isspace((unsigned char) *str) && !strchr("#,.()\"", *str))
316316
{
317317
/*
318318
* 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)
351351
found_space = false;
352352

353353
/* skip ending whitespaces */
354-
while (isspace(*str))
354+
while (isspace((unsigned char) *str))
355355
{
356356
found_space = true;
357357
str++;
@@ -400,7 +400,7 @@ filter_read_item(FilterStateData *fstate,
400400
fstate->lineno++;
401401

402402
/* Skip initial white spaces */
403-
while (isspace(*str))
403+
while (isspace((unsigned char) *str))
404404
str++;
405405

406406
/*

0 commit comments

Comments
 (0)