Skip to content
Snippets Groups Projects
Commit 333b7db8 authored by Noah Misch's avatar Noah Misch
Browse files

Consistently pass an "unsigned char" to ctype.h functions.

The isxdigit() calls relied on undefined behavior.  The isascii() call
was well-defined, but our prevailing style is to include the cast.
Back-patch to 9.4, where the isxdigit() calls were introduced.
parent e254ff21
No related branches found
No related tags found
No related merge requests found
...@@ -154,7 +154,7 @@ get_control_data(ClusterInfo *cluster, bool live_check) ...@@ -154,7 +154,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
if (GET_MAJOR_VERSION(cluster->major_version) <= 803) if (GET_MAJOR_VERSION(cluster->major_version) <= 803)
{ {
for (p = bufin; *p; p++) for (p = bufin; *p; p++)
if (!isascii(*p)) if (!isascii((unsigned char) *p))
pg_fatal("The 8.3 cluster's pg_controldata is incapable of outputting ASCII, even\n" pg_fatal("The 8.3 cluster's pg_controldata is incapable of outputting ASCII, even\n"
"with LANG=C. You must upgrade this cluster to a newer version of PostgreSQL\n" "with LANG=C. You must upgrade this cluster to a newer version of PostgreSQL\n"
"8.3 to fix this bug. PostgreSQL 8.3.7 and later are known to work properly.\n"); "8.3 to fix this bug. PostgreSQL 8.3.7 and later are known to work properly.\n");
......
...@@ -2353,8 +2353,11 @@ escape_json(StringInfo buf, const char *str) ...@@ -2353,8 +2353,11 @@ escape_json(StringInfo buf, const char *str)
* only unicode escape that should be present is \u0000, * only unicode escape that should be present is \u0000,
* all the other unicode escapes will have been resolved. * all the other unicode escapes will have been resolved.
*/ */
if (p[1] == 'u' && isxdigit(p[2]) && isxdigit(p[3]) if (p[1] == 'u' &&
&& isxdigit(p[4]) && isxdigit(p[5])) isxdigit((unsigned char) p[2]) &&
isxdigit((unsigned char) p[3]) &&
isxdigit((unsigned char) p[4]) &&
isxdigit((unsigned char) p[5]))
appendStringInfoCharMacro(buf, *p); appendStringInfoCharMacro(buf, *p);
else else
appendStringInfoString(buf, "\\\\"); appendStringInfoString(buf, "\\\\");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment