projects/aports·blob master · refs

1656 lines · 60.5 KiB

1From 759d11985a6265877bcf0783404fde920c9ec0d1 Mon Sep 17 00:00:00 2001
2From: Ilija Tovilo <[email protected]>
3Date: Sun, 3 May 2026 20:03:18 +0200
4Subject: [PATCH 1/7] GHSA-m8rr-4c36-8gq4: Consistently pass unsigned char to
5 ctype.h functions
6
7Fixes GHSA-m8rr-4c36-8gq4
8Fixes CVE-2026-7258
9
10(cherry picked from commit 8bdee7e4c6f4e92f9e89841d53855d9ffbdbfe54)
11---
12 Zend/zend_compile.c | 2 +-
13 Zend/zend_operators.c | 8 ++++----
14 Zend/zend_virtual_cwd.c | 10 +++++-----
15 Zend/zend_virtual_cwd.h | 2 +-
16 ext/com_dotnet/com_extension.c | 4 ++--
17 ext/date/lib/parse_date.c | 10 +++++-----
18 ext/date/lib/parse_date.re | 10 +++++-----
19 ext/date/lib/parse_iso_intervals.c | 4 ++--
20 ext/date/lib/parse_iso_intervals.re | 4 ++--
21 ext/date/lib/timelib.c | 2 +-
22 ext/filter/logical_filters.c | 10 +++++-----
23 ext/ftp/ftp.c | 10 +++++-----
24 ext/gd/libgd/gd_xbm.c | 2 +-
25 ext/imap/php_imap.c | 2 +-
26 ext/intl/locale/locale_methods.c | 2 +-
27 ext/mbstring/mbstring.c | 4 ++--
28 ext/mbstring/php_mbregex.c | 2 +-
29 ext/pcre/php_pcre.c | 4 ++--
30 ext/pdo/pdo.c | 2 +-
31 ext/pdo/pdo_sql_parser.re | 2 +-
32 ext/pdo/pdo_stmt.c | 2 +-
33 ext/standard/dl.c | 2 +-
34 ext/standard/exec.c | 2 +-
35 ext/standard/file.c | 2 +-
36 ext/standard/filters.c | 2 +-
37 ext/standard/formatted_print.c | 8 ++++----
38 ext/standard/ftp_fopen_wrapper.c | 12 ++++++------
39 ext/standard/html.c | 4 ++--
40 ext/standard/math.c | 6 +++---
41 ext/standard/metaphone.c | 18 +++++++++---------
42 ext/standard/quot_print.c | 8 ++++----
43 ext/standard/scanf.c | 10 +++++-----
44 ext/standard/soundex.c | 2 +-
45 ext/standard/string.c | 14 +++++++-------
46 ext/standard/strnatcmp.c | 26 +++++++++++++-------------
47 ext/standard/type.c | 2 +-
48 ext/standard/url.c | 20 ++++++++++----------
49 ext/standard/url_scanner_ex.re | 6 +++---
50 ext/standard/versioning.c | 16 ++++++++--------
51 main/SAPI.c | 6 +++---
52 main/fopen_wrappers.c | 6 +++---
53 main/php_ini.c | 2 +-
54 main/php_variables.c | 4 ++--
55 main/rfc1867.c | 12 ++++++------
56 main/snprintf.c | 14 +++++++-------
57 main/spprintf.c | 14 +++++++-------
58 main/streams/streams.c | 4 ++--
59 main/streams/transports.c | 2 +-
60 sapi/cli/php_cli_server.c | 2 +-
61 sapi/fpm/fpm/fpm_conf.c | 4 ++--
62 sapi/litespeed/lsapi_main.c | 4 ++--
63 sapi/litespeed/lsapilib.c | 6 +++---
64 sapi/phpdbg/phpdbg_cmd.c | 4 ++--
65 sapi/phpdbg/phpdbg_prompt.c | 2 +-
66 sapi/phpdbg/phpdbg_utils.c | 10 +++++-----
67 win32/sendmail.c | 6 +++---
68 56 files changed, 180 insertions(+), 180 deletions(-)
69
70diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
71index c0cd3c97341..856e81ace7f 100644
72--- a/Zend/zend_compile.c
73+++ b/Zend/zend_compile.c
74@@ -2006,7 +2006,7 @@ ZEND_API size_t zend_dirname(char *path, size_t len)
75 /* Note that on Win32 CWD is per drive (heritage from CP/M).
76 * This means dirname("c:foo") maps to "c:." or "c:" - which means CWD on C: drive.
77 */
78- if ((2 <= len) && isalpha((int)((unsigned char *)path)[0]) && (':' == path[1])) {
79+ if ((2 <= len) && isalpha((unsigned char)path[0]) && (':' == path[1])) {
80 /* Skip over the drive spec (if any) so as not to change */
81 path += 2;
82 len_adjust += 2;
83diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
84index ef5c50c4336..1c4abc9ede5 100644
85--- a/Zend/zend_operators.c
86+++ b/Zend/zend_operators.c
87@@ -2883,8 +2883,8 @@ ZEND_API int ZEND_FASTCALL zend_binary_strcasecmp_l(const char *s1, size_t len1,
88
89 len = MIN(len1, len2);
90 while (len--) {
91- c1 = zend_tolower((int)*(unsigned char *)s1++);
92- c2 = zend_tolower((int)*(unsigned char *)s2++);
93+ c1 = zend_tolower((unsigned char)*(s1++));
94+ c2 = zend_tolower((unsigned char)*(s2++));
95 if (c1 != c2) {
96 return c1 - c2;
97 }
98@@ -2904,8 +2904,8 @@ ZEND_API int ZEND_FASTCALL zend_binary_strncasecmp_l(const char *s1, size_t len1
99 }
100 len = MIN(length, MIN(len1, len2));
101 while (len--) {
102- c1 = zend_tolower((int)*(unsigned char *)s1++);
103- c2 = zend_tolower((int)*(unsigned char *)s2++);
104+ c1 = zend_tolower((unsigned char)*(s1++));
105+ c2 = zend_tolower((unsigned char)*(s2++));
106 if (c1 != c2) {
107 return c1 - c2;
108 }
109diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c
110index d8a9046d04d..ca5f79d9933 100644
111--- a/Zend/zend_virtual_cwd.c
112+++ b/Zend/zend_virtual_cwd.c
113@@ -195,7 +195,7 @@ void virtual_cwd_main_cwd_init(uint8_t reinit) /* {{{ */
114 main_cwd_state.cwd_length = strlen(cwd);
115 #ifdef ZEND_WIN32
116 if (main_cwd_state.cwd_length >= 2 && cwd[1] == ':') {
117- cwd[0] = toupper(cwd[0]);
118+ cwd[0] = toupper((unsigned char)cwd[0]);
119 }
120 #endif
121 main_cwd_state.cwd = strdup(cwd);
122@@ -273,7 +273,7 @@ CWD_API char *virtual_getcwd_ex(size_t *length) /* {{{ */
123 *length = state->cwd_length+1;
124 retval = (char *) emalloc(*length+1);
125 memcpy(retval, state->cwd, *length);
126- retval[0] = toupper(retval[0]);
127+ retval[0] = toupper((unsigned char)retval[0]);
128 retval[*length-1] = DEFAULT_SLASH;
129 retval[*length] = '\0';
130 return retval;
131@@ -1114,7 +1114,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
132 if (resolved_path[start] == 0) {
133 goto verify;
134 }
135- resolved_path[start] = toupper(resolved_path[start]);
136+ resolved_path[start] = toupper((unsigned char)resolved_path[start]);
137 start++;
138 }
139 resolved_path[start++] = DEFAULT_SLASH;
140@@ -1122,13 +1122,13 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
141 if (resolved_path[start] == 0) {
142 goto verify;
143 }
144- resolved_path[start] = toupper(resolved_path[start]);
145+ resolved_path[start] = toupper((unsigned char)resolved_path[start]);
146 start++;
147 }
148 resolved_path[start++] = DEFAULT_SLASH;
149 } else if (IS_ABSOLUTE_PATH(resolved_path, path_length)) {
150 /* skip DRIVE name */
151- resolved_path[0] = toupper(resolved_path[0]);
152+ resolved_path[0] = toupper((unsigned char)resolved_path[0]);
153 resolved_path[2] = DEFAULT_SLASH;
154 start = 3;
155 }
156diff --git a/Zend/zend_virtual_cwd.h b/Zend/zend_virtual_cwd.h
157index 728e3ba69d8..d15c8e28d5d 100644
158--- a/Zend/zend_virtual_cwd.h
159+++ b/Zend/zend_virtual_cwd.h
160@@ -82,7 +82,7 @@ typedef unsigned short mode_t;
161 #define IS_UNC_PATH(path, len) \
162 (len >= 2 && IS_SLASH(path[0]) && IS_SLASH(path[1]))
163 #define IS_ABSOLUTE_PATH(path, len) \
164- (len >= 2 && (/* is local */isalpha(path[0]) && path[1] == ':' || /* is UNC */IS_SLASH(path[0]) && IS_SLASH(path[1])))
165+ (len >= 2 && (/* is local */isalpha((unsigned char)(path)[0]) && path[1] == ':' || /* is UNC */IS_SLASH(path[0]) && IS_SLASH(path[1])))
166
167 #else
168 #ifdef HAVE_DIRENT_H
169diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c
170index 55b3c282aee..380ca0791e8 100644
171--- a/ext/com_dotnet/com_extension.c
172+++ b/ext/com_dotnet/com_extension.c
173@@ -104,11 +104,11 @@ static PHP_INI_MH(OnTypeLibFileUpdate)
174 }
175
176 /* Remove leading/training white spaces on search_string */
177- while (isspace(*typelib_name)) {/* Ends on '\0' in worst case */
178+ while (isspace((unsigned char)*typelib_name)) {/* Ends on '\0' in worst case */
179 typelib_name ++;
180 }
181 ptr = typelib_name + strlen(typelib_name) - 1;
182- while ((ptr != typelib_name) && isspace(*ptr)) {
183+ while ((ptr != typelib_name) && isspace((unsigned char)*ptr)) {
184 *ptr = '\0';
185 ptr--;
186 }
187diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c
188index 78feb742081..9c5c9d602a1 100644
189--- a/ext/date/lib/parse_date.c
190+++ b/ext/date/lib/parse_date.c
191@@ -509,7 +509,7 @@ static timelib_sll timelib_get_nr(const char **ptr, int max_length)
192
193 static void timelib_skip_day_suffix(const char **ptr)
194 {
195- if (isspace(**ptr)) {
196+ if (isspace((unsigned char)**ptr)) {
197 return;
198 }
199 if (!timelib_strncasecmp(*ptr, "nd", 2) || !timelib_strncasecmp(*ptr, "rd", 2) ||!timelib_strncasecmp(*ptr, "st", 2) || !timelib_strncasecmp(*ptr, "th", 2)) {
200@@ -792,7 +792,7 @@ static timelib_long timelib_parse_tz_cor(const char **ptr, int *tz_not_found)
201
202 *tz_not_found = 1;
203
204- while (isdigit(**ptr) || **ptr == ':') {
205+ while (isdigit((unsigned char)**ptr) || **ptr == ':') {
206 ++*ptr;
207 }
208 end = *ptr;
209@@ -857,7 +857,7 @@ static timelib_long timelib_parse_tz_minutes(const char **ptr, timelib_time *t)
210 }
211
212 ++*ptr;
213- while (isdigit(**ptr)) {
214+ while (isdigit((unsigned char)**ptr)) {
215 ++*ptr;
216 }
217
218@@ -25936,10 +25936,10 @@ timelib_time *timelib_strtotime(const char *s, size_t len, timelib_error_contain
219 in.errors->error_messages = NULL;
220
221 if (len > 0) {
222- while (isspace(*s) && s < e) {
223+ while (isspace((unsigned char)*s) && s < e) {
224 s++;
225 }
226- while (isspace(*e) && e > s) {
227+ while (isspace((unsigned char)*e) && e > s) {
228 e--;
229 }
230 }
231diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re
232index f0db34d302b..a2d12361df9 100644
233--- a/ext/date/lib/parse_date.re
234+++ b/ext/date/lib/parse_date.re
235@@ -507,7 +507,7 @@ static timelib_sll timelib_get_nr(const char **ptr, int max_length)
236
237 static void timelib_skip_day_suffix(const char **ptr)
238 {
239- if (isspace(**ptr)) {
240+ if (isspace((unsigned char)**ptr)) {
241 return;
242 }
243 if (!timelib_strncasecmp(*ptr, "nd", 2) || !timelib_strncasecmp(*ptr, "rd", 2) ||!timelib_strncasecmp(*ptr, "st", 2) || !timelib_strncasecmp(*ptr, "th", 2)) {
244@@ -790,7 +790,7 @@ static timelib_long timelib_parse_tz_cor(const char **ptr, int *tz_not_found)
245
246 *tz_not_found = 1;
247
248- while (isdigit(**ptr) || **ptr == ':') {
249+ while (isdigit((unsigned char)**ptr) || **ptr == ':') {
250 ++*ptr;
251 }
252 end = *ptr;
253@@ -855,7 +855,7 @@ static timelib_long timelib_parse_tz_minutes(const char **ptr, timelib_time *t)
254 }
255
256 ++*ptr;
257- while (isdigit(**ptr)) {
258+ while (isdigit((unsigned char)**ptr)) {
259 ++*ptr;
260 }
261
262@@ -1938,10 +1938,10 @@ timelib_time *timelib_strtotime(const char *s, size_t len, timelib_error_contain
263 in.errors->error_messages = NULL;
264
265 if (len > 0) {
266- while (isspace(*s) && s < e) {
267+ while (isspace((unsigned char)*s) && s < e) {
268 s++;
269 }
270- while (isspace(*e) && e > s) {
271+ while (isspace((unsigned char)*e) && e > s) {
272 e--;
273 }
274 }
275diff --git a/ext/date/lib/parse_iso_intervals.c b/ext/date/lib/parse_iso_intervals.c
276index a467da3471f..113343f5615 100644
277--- a/ext/date/lib/parse_iso_intervals.c
278+++ b/ext/date/lib/parse_iso_intervals.c
279@@ -948,10 +948,10 @@ void timelib_strtointerval(const char *s, size_t len,
280 in.errors->error_messages = NULL;
281
282 if (len > 0) {
283- while (isspace(*s) && s < e) {
284+ while (isspace((unsigned char)*s) && s < e) {
285 s++;
286 }
287- while (isspace(*e) && e > s) {
288+ while (isspace((unsigned char)*e) && e > s) {
289 e--;
290 }
291 }
292diff --git a/ext/date/lib/parse_iso_intervals.re b/ext/date/lib/parse_iso_intervals.re
293index 2a394156f98..00942007751 100644
294--- a/ext/date/lib/parse_iso_intervals.re
295+++ b/ext/date/lib/parse_iso_intervals.re
296@@ -343,10 +343,10 @@ void timelib_strtointerval(const char *s, size_t len,
297 in.errors->error_messages = NULL;
298
299 if (len > 0) {
300- while (isspace(*s) && s < e) {
301+ while (isspace((unsigned char)*s) && s < e) {
302 s++;
303 }
304- while (isspace(*e) && e > s) {
305+ while (isspace((unsigned char)*e) && e > s) {
306 e--;
307 }
308 }
309diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c
310index d42c69bbd6f..9949225df7e 100644
311--- a/ext/date/lib/timelib.c
312+++ b/ext/date/lib/timelib.c
313@@ -126,7 +126,7 @@ void timelib_time_tz_abbr_update(timelib_time* tm, const char* tz_abbr)
314 TIMELIB_TIME_FREE(tm->tz_abbr);
315 tm->tz_abbr = timelib_strdup(tz_abbr);
316 for (i = 0; i < tz_abbr_len; i++) {
317- tm->tz_abbr[i] = toupper(tz_abbr[i]);
318+ tm->tz_abbr[i] = toupper((unsigned char)tz_abbr[i]);
319 }
320 }
321
322diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
323index 3db0ef40905..472e2768651 100644
324--- a/ext/filter/logical_filters.c
325+++ b/ext/filter/logical_filters.c
326@@ -528,21 +528,21 @@ static int _php_filter_validate_domain(char * domain, size_t len, zend_long flag
327 }
328
329 /* First char must be alphanumeric */
330- if(*s == '.' || (hostname && !isalnum((int)*(unsigned char *)s))) {
331+ if(*s == '.' || (hostname && !isalnum((unsigned char)*s))) {
332 return 0;
333 }
334
335 while (s < e) {
336 if (*s == '.') {
337 /* The first and the last character of a label must be alphanumeric */
338- if (*(s + 1) == '.' || (hostname && (!isalnum((int)*(unsigned char *)(s - 1)) || !isalnum((int)*(unsigned char *)(s + 1))))) {
339+ if (*(s + 1) == '.' || (hostname && (!isalnum((unsigned char)s[-1]) || !isalnum((unsigned char)s[1])))) {
340 return 0;
341 }
342
343 /* Reset label length counter */
344 i = 1;
345 } else {
346- if (i > 63 || (hostname && *s != '-' && !isalnum((int)*(unsigned char *)s))) {
347+ if (i > 63 || (hostname && *s != '-' && !isalnum((unsigned char)*s))) {
348 return 0;
349 }
350
351@@ -569,9 +569,9 @@ static int is_userinfo_valid(zend_string *str)
352 const char *valid = "-._~!$&'()*+,;=:";
353 const char *p = ZSTR_VAL(str);
354 while (p - ZSTR_VAL(str) < ZSTR_LEN(str)) {
355- if (isalpha(*p) || isdigit(*p) || strchr(valid, *p)) {
356+ if (isalpha((unsigned char)*p) || isdigit((unsigned char)*p) || strchr(valid, *p)) {
357 p++;
358- } else if (*p == '%' && p - ZSTR_VAL(str) <= ZSTR_LEN(str) - 3 && isdigit(*(p+1)) && isxdigit(*(p+2))) {
359+ } else if (*p == '%' && p - ZSTR_VAL(str) <= ZSTR_LEN(str) - 3 && isdigit((unsigned char)p[1]) && isxdigit((unsigned char)p[2])) {
360 p += 3;
361 } else {
362 return 0;
363diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
364index 9253edc5589..9da59eabfb2 100644
365--- a/ext/ftp/ftp.c
366+++ b/ext/ftp/ftp.c
367@@ -499,7 +499,7 @@ ftp_raw(ftpbuf_t *ftp, const char *cmd, const size_t cmd_len, zval *return_value
368 array_init(return_value);
369 while (ftp_readline(ftp)) {
370 add_next_index_string(return_value, ftp->inbuf);
371- if (isdigit(ftp->inbuf[0]) && isdigit(ftp->inbuf[1]) && isdigit(ftp->inbuf[2]) && ftp->inbuf[3] == ' ') {
372+ if (isdigit((unsigned char)ftp->inbuf[0]) && isdigit((unsigned char)ftp->inbuf[1]) && isdigit((unsigned char)ftp->inbuf[2]) && ftp->inbuf[3] == ' ') {
373 return;
374 }
375 }
376@@ -841,7 +841,7 @@ ftp_pasv(ftpbuf_t *ftp, int pasv)
377 return 0;
378 }
379 /* parse out the IP and port */
380- for (ptr = ftp->inbuf; *ptr && !isdigit(*ptr); ptr++);
381+ for (ptr = ftp->inbuf; *ptr && !isdigit((unsigned char)*ptr); ptr++);
382 n = sscanf(ptr, "%lu,%lu,%lu,%lu,%lu,%lu", &b[0], &b[1], &b[2], &b[3], &b[4], &b[5]);
383 if (n != 6) {
384 return 0;
385@@ -1144,7 +1144,7 @@ ftp_mdtm(ftpbuf_t *ftp, const char *path, const size_t path_len)
386 return -1;
387 }
388 /* parse out the timestamp */
389- for (ptr = ftp->inbuf; *ptr && !isdigit(*ptr); ptr++);
390+ for (ptr = ftp->inbuf; *ptr && !isdigit((unsigned char)*ptr); ptr++);
391 n = sscanf(ptr, "%4u%2u%2u%2u%2u%2u", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
392 if (n != 6) {
393 return -1;
394@@ -1342,13 +1342,13 @@ ftp_getresp(ftpbuf_t *ftp)
395 }
396
397 /* Break out when the end-tag is found */
398- if (isdigit(ftp->inbuf[0]) && isdigit(ftp->inbuf[1]) && isdigit(ftp->inbuf[2]) && ftp->inbuf[3] == ' ') {
399+ if (isdigit((unsigned char)ftp->inbuf[0]) && isdigit((unsigned char)ftp->inbuf[1]) && isdigit((unsigned char)ftp->inbuf[2]) && ftp->inbuf[3] == ' ') {
400 break;
401 }
402 }
403
404 /* translate the tag */
405- if (!isdigit(ftp->inbuf[0]) || !isdigit(ftp->inbuf[1]) || !isdigit(ftp->inbuf[2])) {
406+ if (!isdigit((unsigned char)ftp->inbuf[0]) || !isdigit((unsigned char)ftp->inbuf[1]) || !isdigit((unsigned char)ftp->inbuf[2])) {
407 return 0;
408 }
409
410diff --git a/ext/gd/libgd/gd_xbm.c b/ext/gd/libgd/gd_xbm.c
411index 3c655a2998c..8efb34fbb0d 100644
412--- a/ext/gd/libgd/gd_xbm.c
413+++ b/ext/gd/libgd/gd_xbm.c
414@@ -191,7 +191,7 @@ void gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOCtx * out)
415 } else {
416 for (i=0; i<l; i++) {
417 /* only in C-locale isalnum() would work */
418- if (!isupper(name[i]) && !islower(name[i]) && !isdigit(name[i])) {
419+ if (!isupper((unsigned char)name[i]) && !islower((unsigned char)name[i]) && !isdigit((unsigned char)name[i])) {
420 name[i] = '_';
421 }
422 }
423diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
424index 5c45e213aa5..74fa59d1c5d 100644
425--- a/ext/imap/php_imap.c
426+++ b/ext/imap/php_imap.c
427@@ -2316,7 +2316,7 @@ PHP_FUNCTION(imap_utf8)
428 #define SPECIAL(c) ((c) <= 0x1f || (c) >= 0x7f)
429
430 /* validate a modified-base64 character */
431-#define B64CHAR(c) (isalnum(c) || (c) == '+' || (c) == ',')
432+#define B64CHAR(c) (isalnum((unsigned char)(c)) || (c) == '+' || (c) == ',')
433
434 /* map the low 64 bits of `n' to the modified-base64 characters */
435 #define B64(n) ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
436diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c
437index 159b3ea0a19..adca3ed3e32 100644
438--- a/ext/intl/locale/locale_methods.c
439+++ b/ext/intl/locale/locale_methods.c
440@@ -1135,7 +1135,7 @@ static int strToMatch(const char* str ,char *retstr)
441 if( *str == '-' ){
442 *retstr = '_';
443 } else {
444- *retstr = tolower(*str);
445+ *retstr = tolower((unsigned char)*str);
446 }
447 str++;
448 retstr++;
449diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
450index 238d74e4838..265356a21ce 100644
451--- a/ext/mbstring/mbstring.c
452+++ b/ext/mbstring/mbstring.c
453@@ -626,7 +626,7 @@ static char *php_mb_rfc1867_getword(const zend_encoding *encoding, char **line,
454
455 static char *php_mb_rfc1867_getword_conf(const zend_encoding *encoding, char *str) /* {{{ */
456 {
457- while (*str && isspace(*(unsigned char *)str)) {
458+ while (*str && isspace((unsigned char)*str)) {
459 ++str;
460 }
461
462@@ -642,7 +642,7 @@ static char *php_mb_rfc1867_getword_conf(const zend_encoding *encoding, char *st
463 } else {
464 char *strend = str;
465
466- while (*strend && !isspace(*(unsigned char *)strend)) {
467+ while (*strend && !isspace((unsigned char)*strend)) {
468 ++strend;
469 }
470 return php_mb_rfc1867_substring_conf(encoding, str, strend - str, 0);
471diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
472index 06f65f5c567..e633f0558da 100644
473--- a/ext/mbstring/php_mbregex.c
474+++ b/ext/mbstring/php_mbregex.c
475@@ -779,7 +779,7 @@ static inline void mb_regex_substitute(
476 continue;
477 }
478 if (name_end[0] == delim) break;
479- if (maybe_num && !isdigit(name_end[0])) maybe_num = 0;
480+ if (maybe_num && !isdigit((unsigned char)name_end[0])) maybe_num = 0;
481 name_end++;
482 }
483 p = name_end + 1;
484diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
485index 6249a807970..65891091256 100644
486--- a/ext/pcre/php_pcre.c
487+++ b/ext/pcre/php_pcre.c
488@@ -648,7 +648,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
489
490 /* Parse through the leading whitespace, and display a warning if we
491 get to the end without encountering a delimiter. */
492- while (isspace((int)*(unsigned char *)p)) p++;
493+ while (isspace((unsigned char)*p)) p++;
494 if (*p == 0) {
495 if (key != regex) {
496 zend_string_release_ex(key, 0);
497@@ -662,7 +662,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
498 /* Get the delimiter and display a warning if it is alphanumeric
499 or a backslash. */
500 delimiter = *p++;
501- if (isalnum((int)*(unsigned char *)&delimiter) || delimiter == '\\') {
502+ if (isalnum((unsigned char)delimiter) || delimiter == '\\') {
503 if (key != regex) {
504 zend_string_release_ex(key, 0);
505 }
506diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c
507index b18efe46284..03925abbc3b 100644
508--- a/ext/pdo/pdo.c
509+++ b/ext/pdo/pdo.c
510@@ -229,7 +229,7 @@ PDO_API int php_pdo_parse_data_source(const char *data_source, zend_ulong data_s
511 }
512 }
513
514- while (i < data_source_len && isspace(data_source[i])) {
515+ while (i < data_source_len && isspace((unsigned char)data_source[i])) {
516 i++;
517 }
518
519diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re
520index 7f4721d12a6..7d282352396 100644
521--- a/ext/pdo/pdo_sql_parser.re
522+++ b/ext/pdo/pdo_sql_parser.re
523@@ -105,7 +105,7 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, zend_string *inquery, zend_string
524
525 if (t == PDO_PARSER_BIND) {
526 ptrdiff_t len = s.cur - s.tok;
527- if ((ZSTR_VAL(inquery) < (s.cur - len)) && isalnum(*(s.cur - len - 1))) {
528+ if ((ZSTR_VAL(inquery) < (s.cur - len)) && isalnum((unsigned char)s.cur[-len - 1])) {
529 continue;
530 }
531 query_type |= PDO_PLACEHOLDER_NAMED;
532diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
533index c3c466fbdd2..ea2046a134b 100644
534--- a/ext/pdo/pdo_stmt.c
535+++ b/ext/pdo/pdo_stmt.c
536@@ -148,7 +148,7 @@ bool pdo_stmt_describe_columns(pdo_stmt_t *stmt) /* {{{ */
537 stmt->columns[col].name = zend_string_separate(orig_name, 0);
538 char *s = ZSTR_VAL(stmt->columns[col].name);
539 while (*s != '\0') {
540- *s = toupper(*s);
541+ *s = toupper((unsigned char)*s);
542 s++;
543 }
544 break;
545diff --git a/ext/standard/dl.c b/ext/standard/dl.c
546index 0df3848852f..babab64864c 100644
547--- a/ext/standard/dl.c
548+++ b/ext/standard/dl.c
549@@ -93,7 +93,7 @@ PHPAPI void *php_load_shlib(const char *path, char **errp)
550 size_t i = strlen(err);
551 (*errp)=estrdup(err);
552 php_win32_error_msg_free(err);
553- while (i > 0 && isspace((*errp)[i-1])) { (*errp)[i-1] = '\0'; i--; }
554+ while (i > 0 && isspace((unsigned char)(*errp)[i-1])) { (*errp)[i-1] = '\0'; i--; }
555 } else {
556 (*errp) = estrdup("<No message>");
557 }
558diff --git a/ext/standard/exec.c b/ext/standard/exec.c
559index 1831b8eaa54..156eaa2cd3d 100644
560--- a/ext/standard/exec.c
561+++ b/ext/standard/exec.c
562@@ -83,7 +83,7 @@ PHP_MINIT_FUNCTION(exec)
563
564 static size_t strip_trailing_whitespace(char *buf, size_t bufl) {
565 size_t l = bufl;
566- while (l-- > 0 && isspace(((unsigned char *)buf)[l]));
567+ while (l-- > 0 && isspace((unsigned char)buf[l]));
568 if (l != (bufl - 1)) {
569 bufl = l + 1;
570 buf[bufl] = '\0';
571diff --git a/ext/standard/file.c b/ext/standard/file.c
572index 8bab36096b1..bf20702e976 100644
573--- a/ext/standard/file.c
574+++ b/ext/standard/file.c
575@@ -2086,7 +2086,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int
576 inc_len = (bptr < limit ? (*bptr == '\0' ? 1 : php_mblen(bptr, limit - bptr)): 0);
577 if (inc_len == 1) {
578 char *tmp = bptr;
579- while ((*tmp != delimiter) && isspace((int)*(unsigned char *)tmp)) {
580+ while ((*tmp != delimiter) && isspace((unsigned char)*tmp)) {
581 tmp++;
582 }
583 if (*tmp == enclosure && tmp < limit) {
584diff --git a/ext/standard/filters.c b/ext/standard/filters.c
585index 9b54b3deab1..08678f8d5d8 100644
586--- a/ext/standard/filters.c
587+++ b/ext/standard/filters.c
588@@ -958,7 +958,7 @@ static php_conv_err_t php_conv_qprint_decode_convert(php_conv_qprint_decode *ins
589 goto out;
590 }
591
592- if (!isxdigit((int) *ps)) {
593+ if (!isxdigit(*ps)) {
594 err = PHP_CONV_ERR_INVALID_SEQ;
595 goto out;
596 }
597diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
598index b988422df21..a1927b5fe88 100644
599--- a/ext/standard/formatted_print.c
600+++ b/ext/standard/formatted_print.c
601@@ -378,7 +378,7 @@ php_sprintf_getnumber(char **buffer, size_t *len)
602
603 int php_sprintf_get_argnum(char **format, size_t *format_len) {
604 char *temppos = *format;
605- while (isdigit((int) *temppos)) temppos++;
606+ while (isdigit((unsigned char)*temppos)) temppos++;
607 if (*temppos != '$') {
608 return ARG_NUM_NEXT;
609 }
610@@ -466,7 +466,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
611
612 PRINTF_DEBUG(("sprintf: first looking at '%c', inpos=%d\n",
613 *format, format - Z_STRVAL_P(z_format)));
614- if (isalpha((int)*format)) {
615+ if (isalpha((unsigned char)*format)) {
616 width = precision = 0;
617 argnum = ARG_NUM_NEXT;
618 } else {
619@@ -535,7 +535,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
620 }
621 width = Z_LVAL_P(tmp);
622 adjusting |= ADJ_WIDTH;
623- } else if (isdigit((int)*format)) {
624+ } else if (isdigit((unsigned char)*format)) {
625 PRINTF_DEBUG(("sprintf: getting width\n"));
626 if ((width = php_sprintf_getnumber(&format, &format_len)) < 0) {
627 zend_value_error("Width must be greater than zero and less than %d", INT_MAX);
628@@ -580,7 +580,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
629 precision = Z_LVAL_P(tmp);
630 adjusting |= ADJ_PRECISION;
631 expprec = 1;
632- } else if (isdigit((int)*format)) {
633+ } else if (isdigit((unsigned char)*format)) {
634 if ((precision = php_sprintf_getnumber(&format, &format_len)) < 0) {
635 zend_value_error("Precision must be greater than zero and less than %d", INT_MAX);
636 goto fail;
637diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c
638index d19113f7c77..c7491179fa9 100644
639--- a/ext/standard/ftp_fopen_wrapper.c
640+++ b/ext/standard/ftp_fopen_wrapper.c
641@@ -78,8 +78,8 @@ static inline int get_ftp_result(php_stream *stream, char *buffer, size_t buffer
642 {
643 buffer[0] = '\0'; /* in case read fails to read anything */
644 while (php_stream_gets(stream, buffer, buffer_size-1) &&
645- !(isdigit((int) buffer[0]) && isdigit((int) buffer[1]) &&
646- isdigit((int) buffer[2]) && buffer[3] == ' '));
647+ !(isdigit((unsigned char)buffer[0]) && isdigit((unsigned char)buffer[1]) &&
648+ isdigit((unsigned char)buffer[2]) && buffer[3] == ' '));
649 return strtol(buffer, NULL, 10);
650 }
651 /* }}} */
652@@ -228,7 +228,7 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char
653 #define PHP_FTP_CNTRL_CHK(val, val_len, err_msg) { \
654 unsigned char *s = (unsigned char *) val, *e = (unsigned char *) s + val_len; \
655 while (s < e) { \
656- if (iscntrl(*s)) { \
657+ if (iscntrl((unsigned char)*s)) { \
658 php_stream_wrapper_log_error(wrapper, options, err_msg, val); \
659 goto connect_errexit; \
660 } \
661@@ -339,14 +339,14 @@ static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, size_t ip_
662 /* parse pasv command (129, 80, 95, 25, 13, 221) */
663 tpath = tmp_line;
664 /* skip over the "227 Some message " part */
665- for (tpath += 4; *tpath && !isdigit((int) *tpath); tpath++);
666+ for (tpath += 4; *tpath && !isdigit((unsigned char)*tpath); tpath++);
667 if (!*tpath) {
668 return 0;
669 }
670 /* skip over the host ip, to get the port */
671 hoststart = tpath;
672 for (i = 0; i < 4; i++) {
673- for (; isdigit((int) *tpath); tpath++);
674+ for (; isdigit((unsigned char)*tpath); tpath++);
675 if (*tpath != ',') {
676 return 0;
677 }
678@@ -826,7 +826,7 @@ static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, const char *url,
679 struct tm tm, tmbuf, *gmt;
680 time_t stamp;
681
682- while ((size_t)(p - tmp_line) < sizeof(tmp_line) && !isdigit(*p)) {
683+ while ((size_t)(p - tmp_line) < sizeof(tmp_line) && !isdigit((unsigned char)*p)) {
684 p++;
685 }
686
687diff --git a/ext/standard/html.c b/ext/standard/html.c
688index 14ccd71a236..8d39490b888 100644
689--- a/ext/standard/html.c
690+++ b/ext/standard/html.c
691@@ -682,8 +682,8 @@ static inline int process_numeric_entity(const char **buf, unsigned *code_point)
692
693 /* strtol allows whitespace and other stuff in the beginning
694 * we're not interested */
695- if ((hexadecimal && !isxdigit(**buf)) ||
696- (!hexadecimal && !isdigit(**buf))) {
697+ if ((hexadecimal && !isxdigit((unsigned char)**buf)) ||
698+ (!hexadecimal && !isdigit((unsigned char)**buf))) {
699 return FAILURE;
700 }
701
702diff --git a/ext/standard/math.c b/ext/standard/math.c
703index 8643676b03e..af5869c88bc 100644
704--- a/ext/standard/math.c
705+++ b/ext/standard/math.c
706@@ -727,9 +727,9 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret)
707 e = s + ZSTR_LEN(str);
708
709 /* Skip leading whitespace */
710- while (s < e && isspace(*s)) s++;
711+ while (s < e && isspace((unsigned char)*s)) s++;
712 /* Skip trailing whitespace */
713- while (s < e && isspace(*(e-1))) e--;
714+ while (s < e && isspace((unsigned char)e[-1])) e--;
715
716 if (e - s >= 2) {
717 if (base == 16 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) s += 2;
718@@ -1031,7 +1031,7 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *de
719 tmpbuf = strpprintf(0, "%.*F", dec, d);
720 if (tmpbuf == NULL) {
721 return NULL;
722- } else if (!isdigit((int)ZSTR_VAL(tmpbuf)[0])) {
723+ } else if (!isdigit((unsigned char)ZSTR_VAL(tmpbuf)[0])) {
724 return tmpbuf;
725 }
726
727diff --git a/ext/standard/metaphone.c b/ext/standard/metaphone.c
728index 2ba7a839c88..7aacc146d84 100644
729--- a/ext/standard/metaphone.c
730+++ b/ext/standard/metaphone.c
731@@ -78,7 +78,7 @@ static const char _codes[26] =
732 };
733
734
735-#define ENCODE(c) (isalpha(c) ? _codes[((toupper(c)) - 'A')] : 0)
736+#define ENCODE(c) (isalpha((unsigned char)(c)) ? _codes[((toupper((unsigned char)(c))) - 'A')] : 0)
737
738 #define isvowel(c) (ENCODE(c) & 1) /* AEIOU */
739
740@@ -102,17 +102,17 @@ static const char _codes[26] =
741 * accesssing the array directly... */
742
743 /* Look at the next letter in the word */
744-#define Next_Letter (toupper(word[w_idx+1]))
745+#define Next_Letter (toupper((unsigned char)word[w_idx+1]))
746 /* Look at the current letter in the word */
747-#define Curr_Letter (toupper(word[w_idx]))
748+#define Curr_Letter (toupper((unsigned char)word[w_idx]))
749 /* Go N letters back. */
750-#define Look_Back_Letter(n) (w_idx >= n ? toupper(word[w_idx-n]) : '\0')
751+#define Look_Back_Letter(n) (w_idx >= n ? toupper((unsigned char)word[w_idx-n]) : '\0')
752 /* Previous letter. I dunno, should this return null on failure? */
753 #define Prev_Letter (Look_Back_Letter(1))
754 /* Look two letters down. It makes sure you don't walk off the string. */
755-#define After_Next_Letter (Next_Letter != '\0' ? toupper(word[w_idx+2]) \
756+#define After_Next_Letter (Next_Letter != '\0' ? toupper((unsigned char)word[w_idx+2]) \
757 : '\0')
758-#define Look_Ahead_Letter(n) (toupper(Lookahead((char *) word+w_idx, n)))
759+#define Look_Ahead_Letter(n) (toupper((unsigned char)Lookahead((char *) word+w_idx, n)))
760
761
762 /* Allows us to safely look ahead an arbitrary # of letters */
763@@ -156,7 +156,7 @@ static char Lookahead(char *word, int how_far)
764 #define Phone_Len (p_idx)
765
766 /* Note is a letter is a 'break' in the word */
767-#define Isbreak(c) (!isalpha(c))
768+#define Isbreak(c) (!isalpha((unsigned char)(c)))
769
770 /* {{{ metaphone */
771 static void metaphone(unsigned char *word, size_t word_len, zend_long max_phonemes, zend_string **phoned_word, int traditional)
772@@ -179,7 +179,7 @@ static void metaphone(unsigned char *word, size_t word_len, zend_long max_phonem
773
774 /*-- The first phoneme has to be processed specially. --*/
775 /* Find our first letter */
776- for (; !isalpha(Curr_Letter); w_idx++) {
777+ for (; !isalpha((unsigned char)Curr_Letter); w_idx++) {
778 /* On the off chance we were given nothing but crap... */
779 if (Curr_Letter == '\0') {
780 End_Phoned_Word();
781@@ -263,7 +263,7 @@ static void metaphone(unsigned char *word, size_t word_len, zend_long max_phonem
782 */
783
784 /* Ignore non-alphas */
785- if (!isalpha(Curr_Letter))
786+ if (!isalpha((unsigned char)Curr_Letter))
787 continue;
788
789 /* Drop duplicates, except CC */
790diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c
791index e6aa2e43f4c..fba61f9f484 100644
792--- a/ext/standard/quot_print.c
793+++ b/ext/standard/quot_print.c
794@@ -216,11 +216,11 @@ PHP_FUNCTION(quoted_printable_decode)
795 switch (str_in[i]) {
796 case '=':
797 if (str_in[i + 1] && str_in[i + 2] &&
798- isxdigit((int) str_in[i + 1]) &&
799- isxdigit((int) str_in[i + 2]))
800+ isxdigit((unsigned char)str_in[i + 1]) &&
801+ isxdigit((unsigned char)str_in[i + 2]))
802 {
803- ZSTR_VAL(str_out)[j++] = (php_hex2int((int) str_in[i + 1]) << 4)
804- + php_hex2int((int) str_in[i + 2]);
805+ ZSTR_VAL(str_out)[j++] = (php_hex2int((unsigned char)str_in[i + 1]) << 4)
806+ + php_hex2int((unsigned char)str_in[i + 2]);
807 i += 3;
808 } else /* check for soft line break according to RFC 2045*/ {
809 k = 1;
810diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c
811index 78ecc1642cf..61154eca3a3 100644
812--- a/ext/standard/scanf.c
813+++ b/ext/standard/scanf.c
814@@ -345,7 +345,7 @@ PHPAPI int ValidateFormat(char *format, int numVars, int *totalSubs)
815 goto xpgCheckDone;
816 }
817
818- if ( isdigit( (int)*ch ) ) {
819+ if ( isdigit( (unsigned char)*ch ) ) {
820 /*
821 * Check for an XPG3-style %n$ specification. Note: there
822 * must not be a mixture of XPG3 specs and non-XPG3 specs
823@@ -656,9 +656,9 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
824 /*
825 * If we see whitespace in the format, skip whitespace in the string.
826 */
827- if ( isspace( (int)*ch ) ) {
828+ if ( isspace( (unsigned char)*ch ) ) {
829 sch = *string;
830- while ( isspace( (int)sch ) ) {
831+ while ( isspace( (unsigned char)sch ) ) {
832 if (*string == '\0') {
833 goto done;
834 }
835@@ -809,7 +809,7 @@ literal:
836 if (!(flags & SCAN_NOSKIP)) {
837 while (*string != '\0') {
838 sch = *string;
839- if (! isspace((int)sch) ) {
840+ if (! isspace((unsigned char)sch) ) {
841 break;
842 }
843 string++;
844@@ -835,7 +835,7 @@ literal:
845 end = string;
846 while (*end != '\0') {
847 sch = *end;
848- if ( isspace( (int)sch ) ) {
849+ if ( isspace( (unsigned char)sch ) ) {
850 break;
851 }
852 end++;
853diff --git a/ext/standard/soundex.c b/ext/standard/soundex.c
854index 7d50be97e75..4dded617a65 100644
855--- a/ext/standard/soundex.c
856+++ b/ext/standard/soundex.c
857@@ -67,7 +67,7 @@ PHP_FUNCTION(soundex)
858 /* BUG: should also map here accented letters used in non */
859 /* English words or names (also found in English text!): */
860 /* esstsett, thorn, n-tilde, c-cedilla, s-caron, ... */
861- code = toupper((int)(unsigned char)str[i]);
862+ code = toupper((unsigned char)str[i]);
863 if (code >= 'A' && code <= 'Z') {
864 if (_small == 0) {
865 /* remember first valid char */
866diff --git a/ext/standard/string.c b/ext/standard/string.c
867index da1a97f49da..8ca36ed7186 100644
868--- a/ext/standard/string.c
869+++ b/ext/standard/string.c
870@@ -3534,9 +3534,9 @@ PHPAPI void php_stripcslashes(zend_string *str)
871 case 'f': *target++='\f'; nlen--; break;
872 case '\\': *target++='\\'; nlen--; break;
873 case 'x':
874- if (source+1 < end && isxdigit((int)(*(source+1)))) {
875+ if (source+1 < end && isxdigit((unsigned char)source[1])) {
876 numtmp[0] = *++source;
877- if (source+1 < end && isxdigit((int)(*(source+1)))) {
878+ if (source+1 < end && isxdigit((unsigned char)source[1])) {
879 numtmp[1] = *++source;
880 numtmp[2] = '\0';
881 nlen-=3;
882@@ -4386,7 +4386,7 @@ PHP_FUNCTION(hebrev)
883
884 do {
885 if (block_type == _HEB_BLOCK_TYPE_HEB) {
886- while ((isheb((int)*(tmp+1)) || _isblank((int)*(tmp+1)) || ispunct((int)*(tmp+1)) || (int)*(tmp+1)=='\n' ) && block_end<str_len-1) {
887+ while ((isheb((int)*(tmp+1)) || _isblank((int)*(tmp+1)) || ispunct((unsigned char)tmp[1]) || (int)*(tmp+1)=='\n' ) && block_end<str_len-1) {
888 tmp++;
889 block_end++;
890 block_length++;
891@@ -4436,7 +4436,7 @@ PHP_FUNCTION(hebrev)
892 block_end++;
893 block_length++;
894 }
895- while ((_isblank((int)*tmp) || ispunct((int)*tmp)) && *tmp!='/' && *tmp!='-' && block_end > block_start) {
896+ while ((_isblank((int)*tmp) || ispunct((unsigned char)*tmp)) && *tmp!='/' && *tmp!='-' && block_end > block_start) {
897 tmp--;
898 block_end--;
899 }
900@@ -4818,7 +4818,7 @@ int php_tag_find(char *tag, size_t len, const char *set) {
901 done =1;
902 break;
903 default:
904- if (!isspace((int)c)) {
905+ if (!isspace((unsigned char)c)) {
906 if (state == 0) {
907 state=1;
908 }
909@@ -4908,7 +4908,7 @@ state_0:
910 if (in_q) {
911 break;
912 }
913- if (isspace(*(p + 1)) && !allow_tag_spaces) {
914+ if (isspace((unsigned char)p[1]) && !allow_tag_spaces) {
915 *(rp++) = c;
916 break;
917 }
918@@ -4955,7 +4955,7 @@ state_1:
919 if (in_q) {
920 break;
921 }
922- if (isspace(*(p + 1)) && !allow_tag_spaces) {
923+ if (isspace((unsigned char)p[1]) && !allow_tag_spaces) {
924 goto reg_char_1;
925 }
926 depth++;
927diff --git a/ext/standard/strnatcmp.c b/ext/standard/strnatcmp.c
928index 8cbc0db1c3f..097fc8cdbe9 100644
929--- a/ext/standard/strnatcmp.c
930+++ b/ext/standard/strnatcmp.c
931@@ -40,12 +40,12 @@ compare_right(char const **a, char const *aend, char const **b, char const *bend
932 both numbers to know that they have the same magnitude, so we
933 remember it in BIAS. */
934 for(;; (*a)++, (*b)++) {
935- if ((*a == aend || !isdigit((int)(unsigned char)**a)) &&
936- (*b == bend || !isdigit((int)(unsigned char)**b)))
937+ if ((*a == aend || !isdigit((unsigned char)**a)) &&
938+ (*b == bend || !isdigit((unsigned char)**b)))
939 return bias;
940- else if (*a == aend || !isdigit((int)(unsigned char)**a))
941+ else if (*a == aend || !isdigit((unsigned char)**a))
942 return -1;
943- else if (*b == bend || !isdigit((int)(unsigned char)**b))
944+ else if (*b == bend || !isdigit((unsigned char)**b))
945 return +1;
946 else if (**a < **b) {
947 if (!bias)
948@@ -67,12 +67,12 @@ compare_left(char const **a, char const *aend, char const **b, char const *bend)
949 /* Compare two left-aligned numbers: the first to have a
950 different value wins. */
951 for(;; (*a)++, (*b)++) {
952- if ((*a == aend || !isdigit((int)(unsigned char)**a)) &&
953- (*b == bend || !isdigit((int)(unsigned char)**b)))
954+ if ((*a == aend || !isdigit((unsigned char)**a)) &&
955+ (*b == bend || !isdigit((unsigned char)**b)))
956 return 0;
957- else if (*a == aend || !isdigit((int)(unsigned char)**a))
958+ else if (*a == aend || !isdigit((unsigned char)**a))
959 return -1;
960- else if (*b == bend || !isdigit((int)(unsigned char)**b))
961+ else if (*b == bend || !isdigit((unsigned char)**b))
962 return +1;
963 else if (**a < **b)
964 return -1;
965@@ -103,27 +103,27 @@ PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len
966 ca = *ap; cb = *bp;
967
968 /* skip over leading zeros */
969- while (ca == '0' && (ap+1 < aend) && isdigit((int)(unsigned char)*(ap+1))) {
970+ while (ca == '0' && (ap+1 < aend) && isdigit((unsigned char)ap[1])) {
971 ca = *++ap;
972 }
973
974- while (cb == '0' && (bp+1 < bend) && isdigit((int)(unsigned char)*(bp+1))) {
975+ while (cb == '0' && (bp+1 < bend) && isdigit((unsigned char)bp[1])) {
976 cb = *++bp;
977 }
978
979 while (1) {
980
981 /* Skip consecutive whitespace */
982- while (isspace((int)(unsigned char)ca)) {
983+ while (isspace(ca)) {
984 ca = *++ap;
985 }
986
987- while (isspace((int)(unsigned char)cb)) {
988+ while (isspace(cb)) {
989 cb = *++bp;
990 }
991
992 /* process run of digits */
993- if (isdigit((int)(unsigned char)ca) && isdigit((int)(unsigned char)cb)) {
994+ if (isdigit(ca) && isdigit(cb)) {
995 fractional = (ca == '0' || cb == '0');
996
997 if (fractional)
998diff --git a/ext/standard/type.c b/ext/standard/type.c
999index 93df434fe31..bf56c70d73d 100644
1000--- a/ext/standard/type.c
1001+++ b/ext/standard/type.c
1002@@ -161,7 +161,7 @@ PHP_FUNCTION(intval)
1003 char *strval = Z_STRVAL_P(num);
1004 size_t strlen = Z_STRLEN_P(num);
1005
1006- while (isspace(*strval) && strlen) {
1007+ while (isspace((unsigned char)*strval) && strlen) {
1008 strval++;
1009 strlen--;
1010 }
1011diff --git a/ext/standard/url.c b/ext/standard/url.c
1012index e3d95768fb0..def29df906a 100644
1013--- a/ext/standard/url.c
1014+++ b/ext/standard/url.c
1015@@ -117,7 +117,7 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port
1016 p = s;
1017 while (p < e) {
1018 /* scheme = 1*[ lowalpha | digit | "+" | "-" | "." ] */
1019- if (!isalpha(*p) && !isdigit(*p) && *p != '+' && *p != '.' && *p != '-') {
1020+ if (!isalpha((unsigned char)*p) && !isdigit((unsigned char)*p) && *p != '+' && *p != '.' && *p != '-') {
1021 if (e + 1 < ue && e < binary_strcspn(s, ue, "?#")) {
1022 goto parse_port;
1023 } else if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */
1024@@ -146,7 +146,7 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port
1025 * correctly parse things like a.com:80
1026 */
1027 p = e + 1;
1028- while (p < ue && isdigit(*p)) {
1029+ while (p < ue && isdigit((unsigned char)*p)) {
1030 p++;
1031 }
1032
1033@@ -186,7 +186,7 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port
1034 p = e + 1;
1035 pp = p;
1036
1037- while (pp < ue && pp - p < 6 && isdigit(*pp)) {
1038+ while (pp < ue && pp - p < 6 && isdigit((unsigned char)*pp)) {
1039 pp++;
1040 }
1041
1042@@ -429,12 +429,12 @@ static int php_htoi(char *s)
1043 int value;
1044 int c;
1045
1046- c = ((unsigned char *)s)[0];
1047+ c = (unsigned char)s[0];
1048 if (isupper(c))
1049 c = tolower(c);
1050 value = (c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10) * 16;
1051
1052- c = ((unsigned char *)s)[1];
1053+ c = (unsigned char)s[1];
1054 if (isupper(c))
1055 c = tolower(c);
1056 value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10;
1057@@ -601,8 +601,8 @@ PHPAPI size_t php_url_decode(char *str, size_t len)
1058 if (*data == '+') {
1059 *dest = ' ';
1060 }
1061- else if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1))
1062- && isxdigit((int) *(data + 2))) {
1063+ else if (*data == '%' && len >= 2 && isxdigit((unsigned char)data[1])
1064+ && isxdigit((unsigned char)data[2])) {
1065 *dest = (char) php_htoi(data + 1);
1066 data += 2;
1067 len -= 2;
1068@@ -660,8 +660,8 @@ PHPAPI size_t php_raw_url_decode(char *str, size_t len)
1069 char *data = str;
1070
1071 while (len--) {
1072- if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1))
1073- && isxdigit((int) *(data + 2))) {
1074+ if (*data == '%' && len >= 2 && isxdigit((unsigned char)data[1])
1075+ && isxdigit((unsigned char)data[2])) {
1076 *dest = (char) php_htoi(data + 1);
1077 data += 2;
1078 len -= 2;
1079@@ -722,7 +722,7 @@ no_name_header:
1080 c = *p;
1081 *p = '\0';
1082 s = p + 1;
1083- while (isspace((int)*(unsigned char *)s)) {
1084+ while (isspace((unsigned char)*s)) {
1085 s++;
1086 }
1087
1088diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re
1089index bac49206e63..30b395b3957 100644
1090--- a/ext/standard/url_scanner_ex.re
1091+++ b/ext/standard/url_scanner_ex.re
1092@@ -85,7 +85,7 @@ static int php_ini_on_update_tags(zend_ini_entry *entry, zend_string *new_value,
1093
1094 *val++ = '\0';
1095 for (q = key; *q; q++) {
1096- *q = tolower(*q);
1097+ *q = tolower((unsigned char)*q);
1098 }
1099 keylen = q - key;
1100 str = zend_string_init(key, keylen, 1);
1101@@ -134,7 +134,7 @@ static int php_ini_on_update_hosts(zend_ini_entry *entry, zend_string *new_value
1102 char *q;
1103
1104 for (q = key; *q; q++) {
1105- *q = tolower(*q);
1106+ *q = tolower((unsigned char)*q);
1107 }
1108 keylen = q - key;
1109 if (keylen > 0) {
1110@@ -454,7 +454,7 @@ static inline void handle_tag(STD_PARA)
1111 }
1112 smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
1113 for (i = 0; i < ZSTR_LEN(ctx->tag.s); i++)
1114- ZSTR_VAL(ctx->tag.s)[i] = tolower((int)(unsigned char)ZSTR_VAL(ctx->tag.s)[i]);
1115+ ZSTR_VAL(ctx->tag.s)[i] = tolower((unsigned char)ZSTR_VAL(ctx->tag.s)[i]);
1116 /* intentionally using str_find here, in case the hash value is set, but the string val is changed later */
1117 if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ZSTR_VAL(ctx->tag.s), ZSTR_LEN(ctx->tag.s))) != NULL) {
1118 ok = 1;
1119diff --git a/ext/standard/versioning.c b/ext/standard/versioning.c
1120index aa60d974672..178539709c7 100644
1121--- a/ext/standard/versioning.c
1122+++ b/ext/standard/versioning.c
1123@@ -45,8 +45,8 @@ php_canonicalize_version(const char *version)
1124 * s/([^\d\.])([^\D\.])/$1.$2/g;
1125 * s/([^\D\.])([^\d\.])/$1.$2/g;
1126 */
1127-#define isdig(x) (isdigit(x)&&(x)!='.')
1128-#define isndig(x) (!isdigit(x)&&(x)!='.')
1129+#define isdig(x) (isdigit((unsigned char)(x))&&(x)!='.')
1130+#define isndig(x) (!isdigit((unsigned char)(x))&&(x)!='.')
1131 #define isspecialver(x) ((x)=='-'||(x)=='_'||(x)=='+')
1132
1133 lq = *(q - 1);
1134@@ -59,7 +59,7 @@ php_canonicalize_version(const char *version)
1135 *q++ = '.';
1136 }
1137 *q++ = *p;
1138- } else if (!isalnum(*p)) {
1139+ } else if (!isalnum((unsigned char)*p)) {
1140 if (lq != '.') {
1141 *q++ = '.';
1142 }
1143@@ -152,17 +152,17 @@ php_version_compare(const char *orig_ver1, const char *orig_ver2)
1144 if ((n2 = strchr(p2, '.')) != NULL) {
1145 *n2 = '\0';
1146 }
1147- if (isdigit(*p1) && isdigit(*p2)) {
1148+ if (isdigit((unsigned char)*p1) && isdigit((unsigned char)*p2)) {
1149 /* compare element numerically */
1150 l1 = strtol(p1, NULL, 10);
1151 l2 = strtol(p2, NULL, 10);
1152 compare = ZEND_NORMALIZE_BOOL(l1 - l2);
1153- } else if (!isdigit(*p1) && !isdigit(*p2)) {
1154+ } else if (!isdigit((unsigned char)*p1) && !isdigit((unsigned char)*p2)) {
1155 /* compare element names */
1156 compare = compare_special_version_forms(p1, p2);
1157 } else {
1158 /* mix of names and numbers */
1159- if (isdigit(*p1)) {
1160+ if (isdigit((unsigned char)*p1)) {
1161 compare = compare_special_version_forms("#N#", p2);
1162 } else {
1163 compare = compare_special_version_forms(p1, "#N#");
1164@@ -180,13 +180,13 @@ php_version_compare(const char *orig_ver1, const char *orig_ver2)
1165 }
1166 if (compare == 0) {
1167 if (n1 != NULL) {
1168- if (isdigit(*p1)) {
1169+ if (isdigit((unsigned char)*p1)) {
1170 compare = 1;
1171 } else {
1172 compare = php_version_compare(p1, "#N#");
1173 }
1174 } else if (n2 != NULL) {
1175- if (isdigit(*p2)) {
1176+ if (isdigit((unsigned char)*p2)) {
1177 compare = -1;
1178 } else {
1179 compare = php_version_compare("#N#", p2);
1180diff --git a/main/SAPI.c b/main/SAPI.c
1181index 561cf6d598c..8b47a6c828c 100644
1182--- a/main/SAPI.c
1183+++ b/main/SAPI.c
1184@@ -193,7 +193,7 @@ static void sapi_read_post_data(void)
1185 *p = 0;
1186 break;
1187 default:
1188- *p = tolower(*p);
1189+ *p = tolower((unsigned char)*p);
1190 break;
1191 }
1192 }
1193@@ -710,10 +710,10 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
1194 }
1195
1196 /* cut off trailing spaces, linefeeds and carriage-returns */
1197- if (header_line_len && isspace(header_line[header_line_len-1])) {
1198+ if (header_line_len && isspace((unsigned char)header_line[header_line_len - 1])) {
1199 do {
1200 header_line_len--;
1201- } while(header_line_len && isspace(header_line[header_line_len-1]));
1202+ } while(header_line_len && isspace((unsigned char)header_line[header_line_len - 1]));
1203 header_line[header_line_len]='\0';
1204 }
1205
1206diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
1207index efb110171b1..2ba2615ee6f 100644
1208--- a/main/fopen_wrappers.c
1209+++ b/main/fopen_wrappers.c
1210@@ -487,7 +487,7 @@ PHPAPI zend_string *php_resolve_path(const char *filename, size_t filename_lengt
1211 }
1212
1213 /* Don't resolve paths which contain protocol (except of file://) */
1214- for (p = filename; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++);
1215+ for (p = filename; isalnum((unsigned char)*p) || *p == '+' || *p == '-' || *p == '.'; p++);
1216 if ((*p == ':') && (p - filename > 1) && (p[1] == '/') && (p[2] == '/')) {
1217 wrapper = php_stream_locate_url_wrapper(filename, &actual_path, STREAM_OPEN_FOR_INCLUDE);
1218 if (wrapper == &php_plain_files_wrapper) {
1219@@ -519,7 +519,7 @@ PHPAPI zend_string *php_resolve_path(const char *filename, size_t filename_lengt
1220 /* Check for stream wrapper */
1221 int is_stream_wrapper = 0;
1222
1223- for (p = ptr; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++);
1224+ for (p = ptr; isalnum((unsigned char)*p) || *p == '+' || *p == '-' || *p == '.'; p++);
1225 if ((*p == ':') && (p - ptr > 1) && (p[1] == '/') && (p[2] == '/')) {
1226 /* .:// or ..:// is not a stream wrapper */
1227 if (p[-1] != '.' || p[-2] != '.' || p - 2 != ptr) {
1228@@ -588,7 +588,7 @@ PHPAPI zend_string *php_resolve_path(const char *filename, size_t filename_lengt
1229 actual_path = trypath;
1230
1231 /* Check for stream wrapper */
1232- for (p = trypath; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++);
1233+ for (p = trypath; isalnum((unsigned char)*p) || *p == '+' || *p == '-' || *p == '.'; p++);
1234 if ((*p == ':') && (p - trypath > 1) && (p[1] == '/') && (p[2] == '/')) {
1235 wrapper = php_stream_locate_url_wrapper(trypath, &actual_path, STREAM_OPEN_FOR_INCLUDE);
1236 if (!wrapper) {
1237diff --git a/main/php_ini.c b/main/php_ini.c
1238index 136942896da..f28c7db7de5 100644
1239--- a/main/php_ini.c
1240+++ b/main/php_ini.c
1241@@ -40,7 +40,7 @@
1242 char *tmp = path; \
1243 while (*tmp) { \
1244 if (*tmp == '\\') *tmp = '/'; \
1245- else *tmp = tolower(*tmp); \
1246+ else *tmp = tolower((unsigned char)*tmp); \
1247 tmp++; \
1248 } \
1249 }
1250diff --git a/main/php_variables.c b/main/php_variables.c
1251index da7266416a5..a851c347601 100644
1252--- a/main/php_variables.c
1253+++ b/main/php_variables.c
1254@@ -185,7 +185,7 @@ PHPAPI void php_register_variable_ex(const char *var_name, zval *val, zval *trac
1255
1256 ip++;
1257 index_s = ip;
1258- if (isspace(*ip)) {
1259+ if (isspace((unsigned char)*ip)) {
1260 ip++;
1261 }
1262 if (*ip==']') {
1263@@ -508,7 +508,7 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
1264
1265 if (arg == PARSE_COOKIE) {
1266 /* Remove leading spaces from cookie names, needed for multi-cookie header where ; can be followed by a space */
1267- while (isspace(*var)) {
1268+ while (isspace((unsigned char)*var)) {
1269 var++;
1270 }
1271 if (var == val || *var == '\0') {
1272diff --git a/main/rfc1867.c b/main/rfc1867.c
1273index 83d141d38b1..c57e26b11b9 100644
1274--- a/main/rfc1867.c
1275+++ b/main/rfc1867.c
1276@@ -413,7 +413,7 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
1277 }
1278
1279 /* space in the beginning means same header */
1280- if (!isspace(line[0])) {
1281+ if (!isspace((unsigned char)line[0])) {
1282 value = strchr(line, ':');
1283 }
1284
1285@@ -429,7 +429,7 @@ static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
1286 }
1287
1288 *value = '\0';
1289- do { value++; } while (isspace(*value));
1290+ do { value++; } while (isspace((unsigned char)*value));
1291
1292 key = estrdup(line);
1293 smart_string_appends(&buf_value, value);
1294@@ -526,7 +526,7 @@ static char *substring_conf(char *start, int len, char quote)
1295
1296 static char *php_ap_getword_conf(const zend_encoding *encoding, char *str)
1297 {
1298- while (*str && isspace(*str)) {
1299+ while (*str && isspace((unsigned char)*str)) {
1300 ++str;
1301 }
1302
1303@@ -542,7 +542,7 @@ static char *php_ap_getword_conf(const zend_encoding *encoding, char *str)
1304 } else {
1305 char *strend = str;
1306
1307- while (*strend && !isspace(*strend)) {
1308+ while (*strend && !isspace((unsigned char)*strend)) {
1309 ++strend;
1310 }
1311 return substring_conf(str, strend - str, 0);
1312@@ -809,7 +809,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
1313 goto fileupload_done;
1314 }
1315
1316- while (isspace(*cd)) {
1317+ while (isspace((unsigned char)*cd)) {
1318 ++cd;
1319 }
1320
1321@@ -817,7 +817,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
1322 {
1323 char *key = NULL, *word = pair;
1324
1325- while (isspace(*cd)) {
1326+ while (isspace((unsigned char)*cd)) {
1327 ++cd;
1328 }
1329
1330diff --git a/main/snprintf.c b/main/snprintf.c
1331index f082115c676..b591169012b 100644
1332--- a/main/snprintf.c
1333+++ b/main/snprintf.c
1334@@ -286,7 +286,7 @@ PHPAPI char * php_conv_fp(char format, double num,
1335 /*
1336 * Check for Infinity and NaN
1337 */
1338- if (isalpha((int)*p)) {
1339+ if (isalpha((unsigned char)*p)) {
1340 *len = strlen(p);
1341 memcpy(buf, p, *len + 1);
1342 *is_negative = false;
1343@@ -433,11 +433,11 @@ typedef struct buf_area buffy;
1344 #define NUM( c ) ( c - '0' )
1345
1346 #define STR_TO_DEC( str, num ) \
1347- num = NUM( *str++ ) ; \
1348- while ( isdigit((int)*str ) ) \
1349+ num = NUM( *(str)++ ) ; \
1350+ while ( isdigit((unsigned char)*(str) ) ) \
1351 { \
1352 num *= 10 ; \
1353- num += NUM( *str++ ) ; \
1354+ num += NUM( *(str)++ ) ; \
1355 }
1356
1357 /*
1358@@ -531,7 +531,7 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
1359 /*
1360 * Try to avoid checking for flags, width or precision
1361 */
1362- if (isascii((int)*fmt) && !islower((int)*fmt)) {
1363+ if (isascii((unsigned char)*fmt) && !islower((unsigned char)*fmt)) {
1364 /*
1365 * Recognize flags: -, #, BLANK, +
1366 */
1367@@ -553,7 +553,7 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
1368 /*
1369 * Check if a width was specified
1370 */
1371- if (isdigit((int)*fmt)) {
1372+ if (isdigit((unsigned char)*fmt)) {
1373 STR_TO_DEC(fmt, min_width);
1374 adjust_width = true;
1375 } else if (*fmt == '*') {
1376@@ -573,7 +573,7 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
1377 if (*fmt == '.') {
1378 adjust_precision = true;
1379 fmt++;
1380- if (isdigit((int)*fmt)) {
1381+ if (isdigit((unsigned char)*fmt)) {
1382 STR_TO_DEC(fmt, precision);
1383 } else if (*fmt == '*') {
1384 precision = va_arg(ap, int);
1385diff --git a/main/spprintf.c b/main/spprintf.c
1386index 4c01347fcf4..2a31e3ae38b 100644
1387--- a/main/spprintf.c
1388+++ b/main/spprintf.c
1389@@ -146,12 +146,12 @@
1390 #define NUM(c) (c - '0')
1391
1392 #define STR_TO_DEC(str, num) do { \
1393- num = NUM(*str++); \
1394- while (isdigit((int)*str)) { \
1395+ num = NUM(*(str)++); \
1396+ while (isdigit((unsigned char)*(str))) {\
1397 num *= 10; \
1398- num += NUM(*str++); \
1399+ num += NUM(*(str)++); \
1400 if (num >= INT_MAX / 10) { \
1401- while (isdigit((int)*str++)); \
1402+ while (isdigit((unsigned char)*(str)++)); \
1403 break; \
1404 } \
1405 } \
1406@@ -238,7 +238,7 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
1407 /*
1408 * Try to avoid checking for flags, width or precision
1409 */
1410- if (isascii((int)*fmt) && !islower((int)*fmt)) {
1411+ if (isascii((unsigned char)*fmt) && !islower((unsigned char)*fmt)) {
1412 /*
1413 * Recognize flags: -, #, BLANK, +
1414 */
1415@@ -260,7 +260,7 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
1416 /*
1417 * Check if a width was specified
1418 */
1419- if (isdigit((int)*fmt)) {
1420+ if (isdigit((unsigned char)*fmt)) {
1421 STR_TO_DEC(fmt, min_width);
1422 adjust_width = true;
1423 } else if (*fmt == '*') {
1424@@ -280,7 +280,7 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
1425 if (*fmt == '.') {
1426 adjust_precision = true;
1427 fmt++;
1428- if (isdigit((int)*fmt)) {
1429+ if (isdigit((unsigned char)*fmt)) {
1430 STR_TO_DEC(fmt, precision);
1431 } else if (*fmt == '*') {
1432 precision = va_arg(ap, int);
1433diff --git a/main/streams/streams.c b/main/streams/streams.c
1434index 634c0d58348..030c2453e50 100644
1435--- a/main/streams/streams.c
1436+++ b/main/streams/streams.c
1437@@ -1739,7 +1739,7 @@ static inline int php_stream_wrapper_scheme_validate(const char *protocol, unsig
1438 unsigned int i;
1439
1440 for(i = 0; i < protocol_len; i++) {
1441- if (!isalnum((int)protocol[i]) &&
1442+ if (!isalnum((unsigned char)protocol[i]) &&
1443 protocol[i] != '+' &&
1444 protocol[i] != '-' &&
1445 protocol[i] != '.') {
1446@@ -1819,7 +1819,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const
1447 return (php_stream_wrapper*)((options & STREAM_LOCATE_WRAPPERS_ONLY) ? NULL : &php_plain_files_wrapper);
1448 }
1449
1450- for (p = path; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++) {
1451+ for (p = path; isalnum((unsigned char)*p) || *p == '+' || *p == '-' || *p == '.'; p++) {
1452 n++;
1453 }
1454
1455diff --git a/main/streams/transports.c b/main/streams/transports.c
1456index 35ac4ae27ad..306f7ff5e4b 100644
1457--- a/main/streams/transports.c
1458+++ b/main/streams/transports.c
1459@@ -94,7 +94,7 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, in
1460 }
1461 }
1462
1463- for (p = name; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++) {
1464+ for (p = name; isalnum((unsigned char)*p) || *p == '+' || *p == '-' || *p == '.'; p++) {
1465 n++;
1466 }
1467
1468diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
1469index 82cf5c10d15..ab0ad1d6e5c 100644
1470--- a/sapi/cli/php_cli_server.c
1471+++ b/sapi/cli/php_cli_server.c
1472@@ -633,7 +633,7 @@ static int sapi_cli_server_register_entry_cb(char **entry, int num_args, va_list
1473 if (key[i] == '-') {
1474 key[i] = '_';
1475 } else {
1476- key[i] = toupper(key[i]);
1477+ key[i] = toupper((unsigned char)key[i]);
1478 }
1479 }
1480 spprintf(&real_key, 0, "%s_%s", "HTTP", key);
1481diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c
1482index cc7102eabbc..01c4ee2d573 100644
1483--- a/sapi/fpm/fpm/fpm_conf.c
1484+++ b/sapi/fpm/fpm/fpm_conf.c
1485@@ -932,7 +932,7 @@ static int fpm_conf_process_all_pools(void)
1486 }
1487
1488 for (i = 0; i < strlen(status); i++) {
1489- if (!isalnum(status[i]) && status[i] != '/' && status[i] != '-' && status[i] != '_' && status[i] != '.' && status[i] != '~') {
1490+ if (!isalnum((unsigned char)status[i]) && status[i] != '/' && status[i] != '-' && status[i] != '_' && status[i] != '.' && status[i] != '~') {
1491 zlog(ZLOG_ERROR, "[pool %s] the status path '%s' must contain only the following characters '[alphanum]/_-.~'", wp->config->name, status);
1492 return -1;
1493 }
1494@@ -955,7 +955,7 @@ static int fpm_conf_process_all_pools(void)
1495 }
1496
1497 for (i = 0; i < strlen(ping); i++) {
1498- if (!isalnum(ping[i]) && ping[i] != '/' && ping[i] != '-' && ping[i] != '_' && ping[i] != '.' && ping[i] != '~') {
1499+ if (!isalnum((unsigned char)ping[i]) && ping[i] != '/' && ping[i] != '-' && ping[i] != '_' && ping[i] != '.' && ping[i] != '~') {
1500 zlog(ZLOG_ERROR, "[pool %s] the ping path '%s' must contain only the following characters '[alphanum]/_-.~'", wp->config->name, ping);
1501 return -1;
1502 }
1503diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c
1504index 2b3d83ad4be..3c0c3cafe02 100644
1505--- a/sapi/litespeed/lsapi_main.c
1506+++ b/sapi/litespeed/lsapi_main.c
1507@@ -1707,12 +1707,12 @@ PHP_FUNCTION(litespeed_response_headers)
1508 len = p - h->header;
1509 if (p && len > 0 && len < LSAPI_RESP_HTTP_HEADER_MAX) {
1510 memmove( headerBuf, h->header, len );
1511- while( len > 0 && (isspace( headerBuf[len-1])) ) {
1512+ while( len > 0 && (isspace((unsigned char)headerBuf[len - 1])) ) {
1513 --len;
1514 }
1515 headerBuf[len] = 0;
1516 if ( len ) {
1517- while( isspace(*++p));
1518+ while(isspace((unsigned char)*++p));
1519 add_assoc_string_ex(return_value, headerBuf, len, p);
1520 }
1521 }
1522diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c
1523index 09cd2e6bf9a..038e43137f2 100644
1524--- a/sapi/litespeed/lsapilib.c
1525+++ b/sapi/litespeed/lsapilib.c
1526@@ -2242,7 +2242,7 @@ static char * GetHeaderVar( LSAPI_Request * pReq, const char * name )
1527
1528 while(( pKey < pKeyEnd )&&( *p ))
1529 {
1530- char ch = toupper( *pKey );
1531+ char ch = toupper( (unsigned char)*pKey );
1532 if ((ch != *p )||(( *p == '_' )&&( ch != '-')))
1533 break;
1534 ++p; ++pKey;
1535@@ -2426,7 +2426,7 @@ int LSAPI_ForeachHeader_r( LSAPI_Request * pReq,
1536 if ( ch == '-' )
1537 *p++ = '_';
1538 else
1539- *p++ = toupper( ch );
1540+ *p++ = toupper( (unsigned char)ch );
1541 }
1542 *p = 0;
1543 keyLen += 5;
1544@@ -2671,7 +2671,7 @@ int LSAPI_ParseSockAddr( const char * pBind, struct sockaddr * pAddr )
1545 if ( !pBind )
1546 return -1;
1547
1548- while( isspace( *pBind ) )
1549+ while(isspace( (unsigned char)*pBind ) )
1550 ++pBind;
1551
1552 strncpy(achAddr, pBind, 255);
1553diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c
1554index 7e6a87fcc89..2b18949e8fd 100644
1555--- a/sapi/phpdbg/phpdbg_cmd.c
1556+++ b/sapi/phpdbg/phpdbg_cmd.c
1557@@ -766,9 +766,9 @@ PHPDBG_API char *phpdbg_read_input(const char *buffered) /* {{{ */
1558 }
1559 }
1560
1561- if (buffer && isspace(*buffer)) {
1562+ if (buffer && isspace((unsigned char)*buffer)) {
1563 char *trimmed = buffer;
1564- while (isspace(*trimmed))
1565+ while (isspace((unsigned char)*trimmed))
1566 trimmed++;
1567
1568 trimmed = estrdup(trimmed);
1569diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c
1570index 8ca6d83c78c..ebf36eae781 100644
1571--- a/sapi/phpdbg/phpdbg_prompt.c
1572+++ b/sapi/phpdbg/phpdbg_prompt.c
1573@@ -213,7 +213,7 @@ static void phpdbg_line_init(char *cmd, struct phpdbg_init_state *state) {
1574
1575 state->line++;
1576
1577- while (cmd_len > 0L && isspace(cmd[cmd_len-1])) {
1578+ while (cmd_len > 0L && isspace((unsigned char)cmd[cmd_len-1])) {
1579 cmd_len--;
1580 }
1581
1582diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c
1583index f638d608905..04bc117ffb3 100644
1584--- a/sapi/phpdbg/phpdbg_utils.c
1585+++ b/sapi/phpdbg/phpdbg_utils.c
1586@@ -82,10 +82,10 @@ PHPDBG_API int phpdbg_is_numeric(const char *str) /* {{{ */
1587 return 0;
1588
1589 for (; *str; str++) {
1590- if (isspace(*str) || *str == '-') {
1591+ if (isspace((unsigned char)*str) || *str == '-') {
1592 continue;
1593 }
1594- return isdigit(*str);
1595+ return isdigit((unsigned char)*str);
1596 }
1597 return 0;
1598 } /* }}} */
1599@@ -96,7 +96,7 @@ PHPDBG_API int phpdbg_is_empty(const char *str) /* {{{ */
1600 return 1;
1601
1602 for (; *str; str++) {
1603- if (isspace(*str)) {
1604+ if (isspace((unsigned char)*str)) {
1605 continue;
1606 }
1607 return 0;
1608@@ -199,12 +199,12 @@ PHPDBG_API char *phpdbg_trim(const char *str, size_t len, size_t *new_len) /* {{
1609 const char *p = str;
1610 char *new = NULL;
1611
1612- while (p && isspace(*p)) {
1613+ while (p && isspace((unsigned char)*p)) {
1614 ++p;
1615 --len;
1616 }
1617
1618- while (*p && isspace(*(p + len -1))) {
1619+ while (*p && isspace((unsigned char)p[len - 1])) {
1620 --len;
1621 }
1622
1623diff --git a/win32/sendmail.c b/win32/sendmail.c
1624index d4de4645d67..e08424bf058 100644
1625--- a/win32/sendmail.c
1626+++ b/win32/sendmail.c
1627@@ -57,7 +57,7 @@
1628 efree(response); \
1629 } \
1630 }
1631-#define SMTP_SKIP_SPACE(str) { while (isspace(*str)) { str++; } }
1632+#define SMTP_SKIP_SPACE(str) { while (isspace((unsigned char)*(str))) { (str)++; } }
1633
1634
1635 char seps[] = " ,\t\n";
1636@@ -725,7 +725,7 @@ static int PostHeader(char *RPath, const char *Subject, const char *mailTo, char
1637 headers_lc_len = strlen(headers_lc);
1638
1639 for (i = 0; i < headers_lc_len; i++) {
1640- headers_lc[i] = tolower(headers_lc[i]);
1641+ headers_lc[i] = tolower((unsigned char)headers_lc[i]);
1642 }
1643 }
1644
1645@@ -853,7 +853,7 @@ return 0;
1646
1647 /* Resolve the servers IP */
1648 /*
1649- if (!isdigit(PW32G(mail_host)[0])||!gethostbyname(PW32G(mail_host)))
1650+ if (!isdigit((unsigned char)PW32G(mail_host)[0])||!gethostbyname(PW32G(mail_host)))
1651 {
1652 return (FAILED_TO_RESOLVE_HOST);
1653 }
1654--
16552.53.0
1656