BUILD: tree-wide: cast arguments to tolower/toupper to unsigned char

NetBSD apparently uses macros for tolower/toupper and complains about
the use of char for array subscripts. Let's properly cast all of them
to unsigned char where they are used.

This is needed to fix issue #729.
This commit is contained in:
Willy Tarreau 2020-07-05 21:46:32 +02:00
parent b0be8ae2a8
commit f278eec37a
6 changed files with 13 additions and 13 deletions

View File

@ -79,7 +79,7 @@ static __inline int dns_hostname_cmp(const char *name1, const char *name2, int l
int i;
for (i = 0; i < len; i++)
if (tolower(name1[i]) != tolower(name2[i]))
if (tolower((unsigned char)name1[i]) != tolower((unsigned char)name2[i]))
return -1;
return 0;
}

View File

@ -662,7 +662,7 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
if (!skip_update) {
/* turn it to lower case if needed */
if (isupper((unsigned char)*ptr) && h1m->flags & H1_MF_TOLOWER)
*ptr = tolower(*ptr);
*ptr = tolower((unsigned char)*ptr);
}
EAT_AND_JUMP_OR_RETURN(ptr, end, http_msg_hdr_name, http_msg_ood, state, H1_MSG_HDR_NAME);
}

View File

@ -782,7 +782,7 @@ struct pattern *pat_match_sub(struct sample *smp, struct pattern_expr *expr, int
icase = expr->mflags & PAT_MF_IGNORE_CASE;
if (icase) {
for (c = smp->data.u.str.area; c <= end; c++) {
if (tolower(*c) != tolower(*pattern->ptr.str))
if (tolower((unsigned char)*c) != tolower((unsigned char)*pattern->ptr.str))
continue;
if (strncasecmp(pattern->ptr.str, c, pattern->len) == 0) {
ret = pattern;
@ -847,7 +847,7 @@ static int match_word(struct sample *smp, struct pattern *pattern, int mflags, u
continue;
if (icase) {
if ((tolower(*c) == tolower(*ps)) &&
if ((tolower((unsigned char)*c) == tolower((unsigned char)*ps)) &&
(strncasecmp(ps, c, pl) == 0) &&
(c == end || is_delimiter(c[pl], delimiters)))
return PAT_MATCH;

View File

@ -57,12 +57,12 @@ int exp_replace(char *dst, unsigned int dst_size, char *src, const char *str, co
if (!*str)
return -1;
hex1 = toupper(*str++) - '0';
hex1 = toupper((unsigned char)*str++) - '0';
if (!*str)
return -1;
hex2 = toupper(*str++) - '0';
hex2 = toupper((unsigned char)*str++) - '0';
if (hex1 > 9) hex1 -= 'A' - '9' - 1;
if (hex2 > 9) hex2 -= 'A' - '9' - 1;

View File

@ -2386,7 +2386,7 @@ static int ssl_sock_switchctx_cbk(SSL *ssl, int *al, void *priv)
for (i = 0; i < trash.size; i++) {
if (!servername[i])
break;
trash.area[i] = tolower(servername[i]);
trash.area[i] = tolower((unsigned char)servername[i]);
if (!wildp && (trash.area[i] == '.'))
wildp = &trash.area[i];
}
@ -2681,7 +2681,7 @@ static int ckch_inst_add_cert_sni(SSL_CTX *ctx, struct ckch_inst *ckch_inst,
int j, len;
len = strlen(name);
for (j = 0; j < len && j < trash.size; j++)
trash.area[j] = tolower(name[j]);
trash.area[j] = tolower((unsigned char)name[j]);
if (j >= trash.size)
return -1;
trash.area[j] = 0;
@ -2985,7 +2985,7 @@ static int ssl_sock_populate_sni_keytypes_hplr(const char *str, struct eb_root *
for (i = 0; i < trash.size; i++) {
if (!str[i])
break;
trash.area[i] = tolower(str[i]);
trash.area[i] = tolower((unsigned char)str[i]);
}
trash.area[i] = 0;
node = ebst_lookup(sni_keytypes, trash.area);

View File

@ -3921,7 +3921,7 @@ const char *strnistr(const char *str1, int len_str1, const char *str2, int len_s
return NULL;
for (tmp1 = 0, start = (char *)str1, pptr = (char *)str2, slen = len_str1, plen = len_str2; slen >= plen; start++, slen--) {
while (toupper(*start) != toupper(*str2)) {
while (toupper((unsigned char)*start) != toupper((unsigned char)*str2)) {
start++;
slen--;
tmp1++;
@ -3938,7 +3938,7 @@ const char *strnistr(const char *str1, int len_str1, const char *str2, int len_s
pptr = (char *)str2;
tmp2 = 0;
while (toupper(*sptr) == toupper(*pptr)) {
while (toupper((unsigned char)*sptr) == toupper((unsigned char)*pptr)) {
sptr++;
pptr++;
tmp2++;
@ -4882,8 +4882,8 @@ uint32_t parse_line(char *in, char *out, size_t *outlen, char **args, int *nbarg
*errptr = in;
goto leave;
}
hex1 = toupper(in[2]) - '0';
hex2 = toupper(in[3]) - '0';
hex1 = toupper((unsigned char)in[2]) - '0';
hex2 = toupper((unsigned char)in[3]) - '0';
if (hex1 > 9) hex1 -= 'A' - '9' - 1;
if (hex2 > 9) hex2 -= 'A' - '9' - 1;
tosend = (hex1 << 4) + hex2;