Skip to content

Commit 333b7db

Browse files
committed
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.
1 parent e254ff2 commit 333b7db

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

contrib/pg_upgrade/controldata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
154154
if (GET_MAJOR_VERSION(cluster->major_version) <= 803)
155155
{
156156
for (p = bufin; *p; p++)
157-
if (!isascii(*p))
157+
if (!isascii((unsigned char) *p))
158158
pg_fatal("The 8.3 cluster's pg_controldata is incapable of outputting ASCII, even\n"
159159
"with LANG=C. You must upgrade this cluster to a newer version of PostgreSQL\n"
160160
"8.3 to fix this bug. PostgreSQL 8.3.7 and later are known to work properly.\n");

src/backend/utils/adt/json.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,8 +2353,11 @@ escape_json(StringInfo buf, const char *str)
23532353
* only unicode escape that should be present is \u0000,
23542354
* all the other unicode escapes will have been resolved.
23552355
*/
2356-
if (p[1] == 'u' && isxdigit(p[2]) && isxdigit(p[3])
2357-
&& isxdigit(p[4]) && isxdigit(p[5]))
2356+
if (p[1] == 'u' &&
2357+
isxdigit((unsigned char) p[2]) &&
2358+
isxdigit((unsigned char) p[3]) &&
2359+
isxdigit((unsigned char) p[4]) &&
2360+
isxdigit((unsigned char) p[5]))
23582361
appendStringInfoCharMacro(buf, *p);
23592362
else
23602363
appendStringInfoString(buf, "\\\\");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy