From: Alan T. DeKok Date: Mon, 31 Oct 2022 20:52:56 +0000 (-0400) Subject: ctype macros should take explicitly unsigned input X-Git-Tag: release_3_2_2~84 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d330e94ccbd508f7d86644be2c663dc8adbac0fc;p=thirdparty%2Ffreeradius-server.git ctype macros should take explicitly unsigned input to avoid chars with high bits being converted to negative numbers perl -p -i -e 's/(tolower|toupper|isupper|islower|isdigit|isalpha|isspace|isxdigit)\(\s*\*/${1}((uint8_t) */g' $(find . -name "*.[ch]" -print) perl -p -i -e 's/(tolower|toupper|isupper|islower|isdigit|isalpha|isspace|isxdigit)\(\(int\)/${1}((uint8_t)/g' $(find . -name "*.[ch]" -print) Manual port of commit d80731fd1ff, as some code has changed --- diff --git a/src/lib/dict.c b/src/lib/dict.c index 479bf1104e..c171abd434 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -1359,7 +1359,7 @@ static int sscanf_i(char const *str, unsigned int *pvalue) if (*str == '.') break; - c = memchr(tab, tolower((int) *str), base); + c = memchr(tab, tolower((uint8_t) *str), base); if (!c) return 0; rcode *= base; @@ -2057,9 +2057,9 @@ static int parse_format(char const *fn, int line, char const *format, int *ptype p = format + 7; if ((strlen(p) < 3) || - !isdigit((int) p[0]) || + !isdigit((uint8_t) p[0]) || (p[1] != ',') || - !isdigit((int) p[2]) || + !isdigit((uint8_t) p[2]) || (p[3] && (p[3] != ','))) { fr_strerror_printf("dict_init: %s[%d]: Invalid format for VENDOR. Expected text like \"1,1\", got \"%s\"", fn, line, p); @@ -2130,7 +2130,7 @@ static int process_vendor(char const* fn, int const line, char **argv, /* * Validate all entries */ - if (!isdigit((int) argv[1][0])) { + if (!isdigit((uint8_t) argv[1][0])) { fr_strerror_printf("dict_init: %s[%d]: invalid value", fn, line); return -1; diff --git a/src/lib/getaddrinfo.c b/src/lib/getaddrinfo.c index 2022362d3d..1c8aa9a866 100644 --- a/src/lib/getaddrinfo.c +++ b/src/lib/getaddrinfo.c @@ -287,7 +287,7 @@ int getaddrinfo(char const *hostname, char const *servname, struct addrinfo cons } if (servname) { - if (isdigit((int)*servname)) { + if (isdigit((uint8_t)*servname)) { port = htons(atoi(servname)); } else { struct servent *se; diff --git a/src/lib/misc.c b/src/lib/misc.c index 9dbb73a599..36378ec40c 100644 --- a/src/lib/misc.c +++ b/src/lib/misc.c @@ -864,7 +864,7 @@ uint8_t *ifid_aton(char const *ifid_str, uint8_t *ifid) num_id = 0; if ((idx += 2) > 6) return NULL; - } else if ((pch = strchr(xdigits, tolower(*p))) != NULL) { + } else if ((pch = strchr(xdigits, tolower((uint8_t) *p))) != NULL) { if (++num_id > 4) return NULL; /* @@ -1325,8 +1325,8 @@ size_t fr_hex2bin(uint8_t *bin, size_t outlen, char const *hex, size_t inlen) if (len > outlen) len = outlen; for (i = 0; i < len; i++) { - if(!(c1 = memchr(hextab, tolower((int) hex[i << 1]), sizeof(hextab))) || - !(c2 = memchr(hextab, tolower((int) hex[(i << 1) + 1]), sizeof(hextab)))) + if(!(c1 = memchr(hextab, tolower((uint8_t) hex[i << 1]), sizeof(hextab))) || + !(c2 = memchr(hextab, tolower((uint8_t) hex[(i << 1) + 1]), sizeof(hextab)))) break; bin[i] = ((c1-hextab)<<4) + (c2-hextab); } @@ -1403,7 +1403,7 @@ uint32_t fr_strtoul(char const *value, char **end) bool is_whitespace(char const *value) { do { - if (!isspace(*value)) return false; + if (!isspace((uint8_t) *value)) return false; value++; } while (*value); @@ -1442,7 +1442,7 @@ bool is_integer(char const *value) { #ifndef __clang_analyzer__ do { - if (!isdigit(*value)) return false; + if (!isdigit((uint8_t) *value)) return false; value++; } while (*value); @@ -1453,7 +1453,7 @@ bool is_integer(char const *value) * other functions doing similar things. */ #else - if (!isdigit(*value)) return false; + if (!isdigit((uint8_t) *value)) return false; #endif return true; diff --git a/src/lib/pair.c b/src/lib/pair.c index 898e1e8529..c86deb8a14 100644 --- a/src/lib/pair.c +++ b/src/lib/pair.c @@ -1795,7 +1795,7 @@ FR_TOKEN fr_pair_raw_from_str(char const **ptr, VALUE_PAIR_RAW *raw) * = * value */ - if ((*p == ':') && (!isdigit((int) p[1]))) { + if ((*p == ':') && (!isdigit((uint8_t) p[1]))) { break; } @@ -1814,13 +1814,13 @@ FR_TOKEN fr_pair_raw_from_str(char const **ptr, VALUE_PAIR_RAW *raw) * Look for tag (:#). This is different from :=, which * is an operator. */ - if ((*p == ':') && (isdigit((int) p[1]))) { + if ((*p == ':') && (isdigit((uint8_t) p[1]))) { if (q >= (raw->l_opand + sizeof(raw->l_opand))) { goto too_long; } *(q++) = *(p++); - while (isdigit((int) *p)) { + while (isdigit((uint8_t) *p)) { if (q >= (raw->l_opand + sizeof(raw->l_opand))) { goto too_long; } diff --git a/src/lib/snprintf.c b/src/lib/snprintf.c index 4f79a32d64..9002464f9e 100644 --- a/src/lib/snprintf.c +++ b/src/lib/snprintf.c @@ -313,7 +313,7 @@ double d; PUT_CHAR('0', p); PUT_CHAR(*p->pf, p); } while (*tmp) { /* hexa */ - PUT_CHAR((*p->pf == 'X' ? toupper(*tmp) : *tmp), p); + PUT_CHAR((*p->pf == 'X' ? toupper((uint8_t) *tmp) : *tmp), p); tmp++; } PAD_LEFT(p); @@ -482,7 +482,7 @@ struct DATA * p; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* gob all the digits */ - for (i = 0; isdigit(*s); i++, s++) + for (i = 0; isdigit((uint8_t) *s); i++, s++) if (i < MAX_FIELD/2 - 1) number[i] = *s; number[i] = '\0'; diff --git a/src/lib/token.c b/src/lib/token.c index a7978622e6..33b858bd62 100644 --- a/src/lib/token.c +++ b/src/lib/token.c @@ -187,7 +187,7 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok, /* Skip whitespace */ p = *ptr; - while (*p && isspace((int) *p)) p++; + while (*p && isspace((uint8_t) *p)) p++; if (!*p) { *ptr = p; @@ -241,7 +241,7 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok, * comma. */ if (!quote) { - if (isspace((int) *p)) { + if (isspace((uint8_t) *p)) { break; } @@ -340,7 +340,7 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok, done: /* Skip whitespace again. */ - while (*p && isspace((int) *p)) p++; + while (*p && isspace((uint8_t) *p)) p++; *ptr = p; @@ -392,7 +392,7 @@ FR_TOKEN getstring(char const **ptr, char *buf, int buflen, bool unescape) p = *ptr; - while (*p && (isspace((int)*p))) p++; + while (*p && (isspace((uint8_t)*p))) p++; *ptr = p; diff --git a/src/lib/value.c b/src/lib/value.c index 05d42e269a..aa4989741c 100644 --- a/src/lib/value.c +++ b/src/lib/value.c @@ -918,11 +918,11 @@ ssize_t value_data_from_str(TALLOC_CTX *ctx, value_data_t *dst, while (*cp) { if (cp[1] == ':') { c1 = hextab; - c2 = memchr(hextab, tolower((int) cp[0]), 16); + c2 = memchr(hextab, tolower((uint8_t) cp[0]), 16); cp += 2; } else if ((cp[1] != '\0') && ((cp[2] == ':') || (cp[2] == '\0'))) { - c1 = memchr(hextab, tolower((int) cp[0]), 16); - c2 = memchr(hextab, tolower((int) cp[1]), 16); + c1 = memchr(hextab, tolower((uint8_t) cp[0]), 16); + c2 = memchr(hextab, tolower((uint8_t) cp[1]), 16); cp += 2; if (*cp == ':') cp++; } else { diff --git a/src/main/client.c b/src/main/client.c index b0b3e24028..b5c38d408f 100644 --- a/src/main/client.c +++ b/src/main/client.c @@ -656,8 +656,8 @@ RADCLIENT_LIST *client_list_parse_section(CONF_SECTION *section, UNUSED bool tls * Check for valid characters */ for (p = dp->d_name; *p != '\0'; p++) { - if (isalpha((int)*p) || - isdigit((int)*p) || + if (isalpha((uint8_t)*p) || + isdigit((uint8_t)*p) || (*p == ':') || (*p == '.')) continue; break; diff --git a/src/main/collectd.c b/src/main/collectd.c index 77f0db0915..b7204719c7 100644 --- a/src/main/collectd.c +++ b/src/main/collectd.c @@ -264,7 +264,7 @@ rs_stats_tmpl_t *rs_stats_collectd_init_latency(TALLOC_CTX *ctx, rs_stats_tmpl_t #define INIT_STATS(_ti, _v) do {\ strlcpy(buffer, fr_packet_codes[code], sizeof(buffer)); \ - for (p = buffer; *p; ++p) *p = tolower(*p);\ + for (p = buffer; *p; ++p) *p = tolower((uint8_t) *p);\ last = *tmpl = rs_stats_collectd_init(ctx, conf, type, _ti, buffer, stats, _v);\ if (!*tmpl) {\ TALLOC_FREE(*out);\ diff --git a/src/main/command.c b/src/main/command.c index 246b54b82e..12d1afdfdb 100644 --- a/src/main/command.c +++ b/src/main/command.c @@ -1661,7 +1661,7 @@ static home_server_t *get_home_server(rad_listen_t *listener, int argc, return NULL; } - if (isdigit(*argv[1])) { + if (isdigit((uint8_t) *argv[1])) { if (ip_hton(&ipaddr, AF_UNSPEC, argv[0], false) < 0) { cprintf_error(listener, "Failed parsing IP address; %s\n", fr_strerror()); diff --git a/src/main/conffile.c b/src/main/conffile.c index 7fe658711f..8a9297b5d6 100644 --- a/src/main/conffile.c +++ b/src/main/conffile.c @@ -2318,7 +2318,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, if (has_spaces) { ptr = cbuf; - while (isspace((int) *ptr)) ptr++; + while (isspace((uint8_t) *ptr)) ptr++; if (ptr > cbuf) { memmove(cbuf, ptr, len - (ptr - cbuf)); @@ -2334,7 +2334,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, if (at_eof) break; ptr = buf; - while (*ptr && isspace((int) *ptr)) ptr++; + while (*ptr && isspace((uint8_t) *ptr)) ptr++; if (!*ptr || (*ptr == '#')) continue; @@ -2524,8 +2524,8 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, * Check for valid characters */ for (p = dp->d_name; *p != '\0'; p++) { - if (isalpha((int)*p) || - isdigit((int)*p) || + if (isalpha((uint8_t)*p) || + isdigit((uint8_t)*p) || (*p == '-') || (*p == '_') || (*p == '.')) continue; @@ -2805,7 +2805,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, case T_OP_EQ: case T_OP_SET: case T_OP_PREPEND: - while (isspace((int) *ptr)) ptr++; + while (isspace((uint8_t) *ptr)) ptr++; /* * Be a little more forgiving. @@ -2827,7 +2827,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, t3 = T_BARE_WORD; while (*q && (*q >= ' ') && (*q != ',') && - !isspace(*q)) q++; + !isspace((uint8_t) *q)) q++; if ((size_t) (q - ptr) >= sizeof(buf3)) { ERROR("%s[%d]: Parse error: value too long", @@ -2898,7 +2898,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, /* * Require a comma, unless there's a comment. */ - while (isspace(*ptr)) ptr++; + while (isspace((uint8_t) *ptr)) ptr++; if (*ptr == ',') { ptr++; @@ -2971,7 +2971,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, /* * Done parsing one thing. Skip to EOL if possible. */ - while (isspace(*ptr)) ptr++; + while (isspace((uint8_t) *ptr)) ptr++; if (*ptr == '#') continue; diff --git a/src/main/evaluate.c b/src/main/evaluate.c index ba214a26ff..c8585b67e0 100644 --- a/src/main/evaluate.c +++ b/src/main/evaluate.c @@ -61,7 +61,7 @@ static bool all_digits(char const *string) if (*p == '-') p++; - while (isdigit((int) *p)) p++; + while (isdigit((uint8_t) *p)) p++; return (*p == '\0'); } diff --git a/src/main/exec.c b/src/main/exec.c index e5ae41df66..67243f79ef 100644 --- a/src/main/exec.c +++ b/src/main/exec.c @@ -152,8 +152,8 @@ pid_t radius_start_program(char const *cmd, REQUEST *request, bool exec_wait, for (p = buffer; *p != '='; p++) { if (*p == '-') { *p = '_'; - } else if (isalpha((int) *p)) { - *p = toupper(*p); + } else if (isalpha((uint8_t) *p)) { + *p = toupper((uint8_t) *p); } } } diff --git a/src/main/files.c b/src/main/files.c index f191393357..25b6f0dc7b 100644 --- a/src/main/files.c +++ b/src/main/files.c @@ -130,7 +130,7 @@ int pairlist_read(TALLOC_CTX *ctx, char const *file, PAIR_LIST **list, int compl * ignore it. */ ptr = buffer; - while (isspace((int) *ptr)) ptr++; + while (isspace((uint8_t) *ptr)) ptr++; if (*ptr == '#' || *ptr == '\n' || !*ptr) continue; @@ -139,7 +139,7 @@ parse_again: /* * The user's name MUST be the first text on the line. */ - if (isspace((int) buffer[0])) { + if (isspace((uint8_t) buffer[0])) { ERROR("%s[%d]: Entry does not begin with a user name", file, lineno); fclose(fp); @@ -158,7 +158,7 @@ parse_again: * $INCLUDE filename */ if (strcasecmp(entry, "$INCLUDE") == 0) { - while (isspace((int) *ptr)) ptr++; + while (isspace((uint8_t) *ptr)) ptr++; /* * If it's an absolute pathname, @@ -261,7 +261,7 @@ parse_again: * We COULD have a reply, OR we could have a new entry. */ if (mode == FIND_MODE_WANT_REPLY) { - if (!isspace((int) buffer[0])) goto create_entry; + if (!isspace((uint8_t) buffer[0])) goto create_entry; mode = FIND_MODE_HAVE_REPLY; } @@ -274,7 +274,7 @@ parse_again: * The previous line ended with a comma, and then * we have the start of a new entry! */ - if (!isspace((int) buffer[0])) { + if (!isspace((uint8_t) buffer[0])) { trailing_comma: pairlist_free(&pl); talloc_free(check_tmp); @@ -335,7 +335,7 @@ parse_again: */ mode = FIND_MODE_NAME; if (feof(fp)) break; - if (!isspace((int) buffer[0])) goto parse_again; + if (!isspace((uint8_t) buffer[0])) goto parse_again; } /* diff --git a/src/main/map.c b/src/main/map.c index 17988d27f9..500615d2af 100644 --- a/src/main/map.c +++ b/src/main/map.c @@ -87,7 +87,7 @@ bool map_cast_from_hex(vp_map_t *map, FR_TOKEN rhs_type, char const *rhs) * string, go parse it as that. */ if (rhs_type != T_BARE_WORD) return false; - if ((rhs[0] != '0') || (tolower((int)rhs[1]) != 'x')) return false; + if ((rhs[0] != '0') || (tolower((uint8_t)rhs[1]) != 'x')) return false; if (!rhs[2]) return false; len = strlen(rhs + 2); diff --git a/src/main/parser.c b/src/main/parser.c index 7bafa8c70b..e337b94fc1 100644 --- a/src/main/parser.c +++ b/src/main/parser.c @@ -303,7 +303,7 @@ static ssize_t condition_tokenize_word(TALLOC_CTX *ctx, char const *start, char /* * Spaces or special characters delineate the word */ - if (isspace((int) *p) || (*p == '&') || (*p == '|') || + if (isspace((uint8_t) *p) || (*p == '&') || (*p == '|') || (*p == '!') || (*p == '=') || (*p == '<') || (*p == '>')) { break; } @@ -335,7 +335,7 @@ static ssize_t condition_tokenize_cast(char const *start, DICT_ATTR const **pda, char const *q; PW_TYPE cast; - while (isspace((int) *p)) p++; /* skip spaces before condition */ + while (isspace((uint8_t) *p)) p++; /* skip spaces before condition */ if (*p != '<') return 0; p++; @@ -378,7 +378,7 @@ static ssize_t condition_tokenize_cast(char const *start, DICT_ATTR const **pda, q++; - while (isspace((int) *q)) q++; /* skip spaces after cast */ + while (isspace((uint8_t) *q)) q++; /* skip spaces after cast */ return q - start; } @@ -503,7 +503,7 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st lhs = rhs = NULL; lhs_type = rhs_type = T_INVALID; - while (isspace((int) *p)) p++; /* skip spaces before condition */ + while (isspace((uint8_t) *p)) p++; /* skip spaces before condition */ if (!*p) { return_P("Empty condition is invalid"); @@ -515,7 +515,7 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st if (*p == '!') { p++; c->negate = true; - while (isspace((int) *p)) p++; /* skip spaces after negation */ + while (isspace((uint8_t) *p)) p++; /* skip spaces after negation */ /* * Just for stupidity @@ -547,7 +547,7 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st } p += slen; - while (isspace((int) *p)) p++; /* skip spaces after (COND)*/ + while (isspace((uint8_t) *p)) p++; /* skip spaces after (COND)*/ } else { /* it's a bare FOO==BAR */ /* @@ -597,7 +597,7 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st c->cast = dict_attrbyvalue(PW_CAST_BASE + PW_TYPE_OCTETS, 0); } - while (isspace((int)*p)) p++; /* skip spaces after LHS */ + while (isspace((uint8_t)*p)) p++; /* skip spaces after LHS */ /* * We may (or not) have an operator @@ -745,7 +745,7 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st break; } - while (isspace((int) *p)) p++; /* skip spaces after operator */ + while (isspace((uint8_t) *p)) p++; /* skip spaces after operator */ if (!*p) { return_P("Expected text after operator"); @@ -1255,7 +1255,7 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st keep_going: p += slen; - while (isspace((int) *p)) p++; /* skip spaces after RHS */ + while (isspace((uint8_t) *p)) p++; /* skip spaces after RHS */ } /* parse OP RHS */ } /* parse a condition (COND) or FOO OP BAR*/ @@ -1268,7 +1268,7 @@ static ssize_t condition_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *st } p++; - while (isspace((int) *p)) p++; /* skip spaces after closing brace */ + while (isspace((uint8_t) *p)) p++; /* skip spaces after closing brace */ goto done; } @@ -1622,7 +1622,7 @@ done: for (q = c->data.vpt->name; *q != '\0'; q++) { - if (!isdigit((int) *q)) { + if (!isdigit((uint8_t) *q)) { break; } if (*q != '0') zeros = false; diff --git a/src/main/radattr.c b/src/main/radattr.c index cf0809c863..57892751ae 100644 --- a/src/main/radattr.c +++ b/src/main/radattr.c @@ -172,7 +172,7 @@ static int encode_data_tlv(char *buffer, char **endptr, *p = '\0'; p = buffer + 1; - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; length = encode_tlv(p, output, outlen); if (length == 0) return 0; @@ -186,12 +186,12 @@ static int encode_hex(char *p, uint8_t *output, size_t outlen) while (*p) { char *c1, *c2; - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if (!*p) break; - if(!(c1 = memchr(hextab, tolower((int) p[0]), 16)) || - !(c2 = memchr(hextab, tolower((int) p[1]), 16))) { + if(!(c1 = memchr(hextab, tolower((uint8_t) p[0]), 16)) || + !(c2 = memchr(hextab, tolower((uint8_t) p[1]), 16))) { fprintf(stderr, "Invalid data starting at " "\"%s\"\n", p); return 0; @@ -217,13 +217,13 @@ static int encode_data(char *p, uint8_t *output, size_t outlen) { int length; - if (!isspace((int) *p)) { + if (!isspace((uint8_t) *p)) { fprintf(stderr, "Invalid character following attribute " "definition\n"); return 0; } - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if (*p == '{') { int sublen; @@ -232,7 +232,7 @@ static int encode_data(char *p, uint8_t *output, size_t outlen) length = 0; do { - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if (!*p) { if (length == 0) { fprintf(stderr, "No data\n"); @@ -642,7 +642,7 @@ static void process_file(const char *root_dir, char const *filename) ((p > buffer) && (p[-1] != '[')))) *p = '\0'; p = buffer; - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if (!*p) continue; DEBUG2("%s[%d]: %s\n", filename, lineno, buffer); @@ -922,7 +922,7 @@ static void process_file(const char *root_dir, char const *filename) char *q; p += 9; - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; q = strrchr(directory, '/'); if (q) { diff --git a/src/main/radclient.c b/src/main/radclient.c index 09d27c8711..37bd406c4a 100644 --- a/src/main/radclient.c +++ b/src/main/radclient.c @@ -1253,7 +1253,7 @@ int main(int argc, char **argv) break; case 'c': - if (!isdigit((int) *optarg)) usage(); + if (!isdigit((uint8_t) *optarg)) usage(); resend_count = atoi(optarg); @@ -1332,7 +1332,7 @@ int main(int argc, char **argv) break; case 'r': - if (!isdigit((int) *optarg)) usage(); + if (!isdigit((uint8_t) *optarg)) usage(); retries = atoi(optarg); if ((retries == 0) || (retries > 1000)) usage(); break; @@ -1372,7 +1372,7 @@ int main(int argc, char **argv) break; case 't': - if (!isdigit((int) *optarg)) + if (!isdigit((uint8_t) *optarg)) usage(); timeout = atof(optarg); break; @@ -1419,7 +1419,7 @@ int main(int argc, char **argv) /* * Get the request type */ - if (!isdigit((int) argv[2][0])) { + if (!isdigit((uint8_t) argv[2][0])) { packet_code = fr_str2int(request_types, argv[2], -2); if (packet_code == -2) { ERROR("Unrecognised request type \"%s\"", argv[2]); diff --git a/src/main/realms.c b/src/main/realms.c index ea2cf6d742..2646796b1e 100644 --- a/src/main/realms.c +++ b/src/main/realms.c @@ -375,7 +375,7 @@ static ssize_t xlat_home_server_dynamic(UNUSED void *instance, REQUEST *request, } p = fmt; - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; /* * Allow for dynamic strings as arguments. @@ -2522,8 +2522,8 @@ int realms_init(CONF_SECTION *config) * Check for valid characters */ for (p = dp->d_name; *p != '\0'; p++) { - if (isalpha((int)*p) || - isdigit((int)*p) || + if (isalpha((uint8_t)*p) || + isdigit((uint8_t)*p) || (*p == '-') || (*p == '_') || (*p == '.')) continue; diff --git a/src/main/tls.c b/src/main/tls.c index c67148cf12..d7d8ece77e 100644 --- a/src/main/tls.c +++ b/src/main/tls.c @@ -365,7 +365,7 @@ static bool identity_is_safe(const char *identity) if (!identity) return true; while ((c = *(identity++)) != '\0') { - if (isalpha((int) c) || isdigit((int) c) || isspace((int) c) || + if (isalpha((uint8_t) c) || isdigit((uint8_t) c) || isspace((uint8_t) c) || (c == '@') || (c == '-') || (c == '_') || (c == '.')) { continue; } diff --git a/src/main/tmpl.c b/src/main/tmpl.c index abcd7687f1..6ec25987ba 100644 --- a/src/main/tmpl.c +++ b/src/main/tmpl.c @@ -153,8 +153,8 @@ size_t radius_list_name(pair_lists_t *out, char const *name, pair_lists_t def) { char const *d = q + 1; - if (isdigit((int) *d)) { - while (isdigit((int) *d)) d++; + if (isdigit((uint8_t) *d)) { + while (isdigit((uint8_t) *d)) d++; /* * Char after the number string diff --git a/src/main/unittest.c b/src/main/unittest.c index 50935c989e..5a15ee2e57 100644 --- a/src/main/unittest.c +++ b/src/main/unittest.c @@ -552,7 +552,7 @@ static bool do_xlats(char const *filename, FILE *fp) * Ignore blank lines and comments */ p = input; - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if (*p < ' ') continue; if (*p == '#') continue; diff --git a/src/main/xlat.c b/src/main/xlat.c index 583686a7db..8000aa1525 100644 --- a/src/main/xlat.c +++ b/src/main/xlat.c @@ -102,7 +102,7 @@ static ssize_t xlat_concat(UNUSED void *instance, REQUEST *request, char const *concat; char buffer[2]; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; slen = tmpl_from_attr_substr(&vpt, fmt, REQUEST_CURRENT, PAIR_LIST_REQUEST, false, false); if (slen <= 0) { @@ -111,7 +111,7 @@ static ssize_t xlat_concat(UNUSED void *instance, REQUEST *request, } fmt += slen; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if (!*fmt) { concat = ","; @@ -148,7 +148,7 @@ static ssize_t xlat_length(UNUSED void *instance, REQUEST *request, char const *fmt, char *out, size_t outlen) { VALUE_PAIR *vp; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) { *out = '\0'; @@ -170,7 +170,7 @@ static ssize_t xlat_integer(UNUSED void *instance, REQUEST *request, uint64_t int64 = 0; /* Needs to be initialised to zero */ uint32_t int32 = 0; /* Needs to be initialised to zero */ - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) { *out = '\0'; @@ -259,7 +259,7 @@ static ssize_t xlat_hex(UNUSED void *instance, REQUEST *request, value_data_t dst; uint8_t const *buff = NULL; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) { error: @@ -314,7 +314,7 @@ static ssize_t xlat_tag(UNUSED void *instance, REQUEST *request, { VALUE_PAIR *vp; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) { *out = '\0'; @@ -338,7 +338,7 @@ static ssize_t xlat_vendor(UNUSED void *instance, REQUEST *request, VALUE_PAIR *vp; DICT_VENDOR *vendor; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) { *out = '\0'; @@ -363,7 +363,7 @@ static ssize_t xlat_vendor_num(UNUSED void *instance, REQUEST *request, { VALUE_PAIR *vp; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) { *out = '\0'; @@ -381,7 +381,7 @@ static ssize_t xlat_attr(UNUSED void *instance, REQUEST *request, { VALUE_PAIR *vp; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) { *out = '\0'; @@ -400,7 +400,7 @@ static ssize_t xlat_attr_num(UNUSED void *instance, REQUEST *request, { VALUE_PAIR *vp; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) { *out = '\0'; @@ -433,7 +433,7 @@ static ssize_t xlat_debug_attr(UNUSED void *instance, REQUEST *request, char con return -1; } - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if (tmpl_from_attr_str(&vpt, fmt, REQUEST_CURRENT, PAIR_LIST_REQUEST, false, false) <= 0) { RDEBUG("%s", fr_strerror()); @@ -644,7 +644,7 @@ static ssize_t xlat_string(UNUSED void *instance, REQUEST *request, VALUE_PAIR *vp; uint8_t const *p; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if (outlen < 3) { nothing: @@ -688,7 +688,7 @@ static ssize_t xlat_xlat(UNUSED void *instance, REQUEST *request, { VALUE_PAIR *vp; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if (outlen < 3) { nothing: @@ -1147,7 +1147,7 @@ ssize_t xlat_fmt_to_ref(uint8_t const **out, REQUEST *request, char const *fmt) { VALUE_PAIR *vp; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if (fmt[0] == '&') { if ((radius_get_vp(&vp, request, fmt) < 0) || !vp) { @@ -1317,7 +1317,7 @@ static ssize_t xlat_tokenize_expansion(TALLOC_CTX *ctx, char *fmt, xlat_exp_t ** for (q = p; *q != '\0'; q++) { if (*q == ':') break; - if (isspace((int) *q)) break; + if (isspace((uint8_t) *q)) break; if (*q == '[') continue; diff --git a/src/modules/proto_dhcp/dhcpclient.c b/src/modules/proto_dhcp/dhcpclient.c index 2ae0a763cb..5ab4365f67 100644 --- a/src/modules/proto_dhcp/dhcpclient.c +++ b/src/modules/proto_dhcp/dhcpclient.c @@ -459,13 +459,13 @@ int main(int argc, char **argv) break; #endif case 'r': - if (!isdigit((int) *optarg)) + if (!isdigit((uint8_t) *optarg)) usage(); retries = atoi(optarg); if ((retries == 0) || (retries > 1000)) usage(); break; case 't': - if (!isdigit((int) *optarg)) + if (!isdigit((uint8_t) *optarg)) usage(); timeout = atof(optarg); break; @@ -530,7 +530,7 @@ int main(int argc, char **argv) * See what kind of request we want to send. */ if (argc >= 3) { - if (!isdigit((int) argv[2][0])) { + if (!isdigit((uint8_t) argv[2][0])) { packet_code = fr_str2int(request_types, argv[2], -2); if (packet_code == -2) { fprintf(stderr, "Unknown packet type: %s\n", argv[2]); diff --git a/src/modules/proto_dhcp/rlm_dhcp.c b/src/modules/proto_dhcp/rlm_dhcp.c index 1cd73ff246..b8a740be29 100644 --- a/src/modules/proto_dhcp/rlm_dhcp.c +++ b/src/modules/proto_dhcp/rlm_dhcp.c @@ -57,7 +57,7 @@ static ssize_t dhcp_options_xlat(UNUSED void *instance, REQUEST *request, int decoded = 0; ssize_t slen; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; slen = tmpl_from_attr_str(&src, fmt, REQUEST_CURRENT, PAIR_LIST_REQUEST, false, false); if (slen <= 0) { @@ -116,7 +116,7 @@ static ssize_t dhcp_xlat(UNUSED void *instance, REQUEST *request, char const *fm uint8_t *p = binbuf, *end = p + sizeof(binbuf); ssize_t slen; - while (isspace((int) *fmt)) fmt++; + while (isspace((uint8_t) *fmt)) fmt++; if ((radius_copy_vp(request, &head, request, fmt) < 0) || !head) { *out = '\0'; diff --git a/src/modules/rlm_counter/rlm_counter.c b/src/modules/rlm_counter/rlm_counter.c index 7f19824dd3..ff46aef0c3 100644 --- a/src/modules/rlm_counter/rlm_counter.c +++ b/src/modules/rlm_counter/rlm_counter.c @@ -271,12 +271,12 @@ static int find_next_reset(rlm_counter_t *inst, time_t timeval) if (!inst->reset) return -1; - if (isdigit((int) inst->reset[0])) { + if (isdigit((uint8_t) inst->reset[0])) { len = strlen(inst->reset); if (len == 0) return -1; last = inst->reset[len - 1]; - if (!isalpha((int) last)) + if (!isalpha((uint8_t) last)) last = 'd'; num = atoi(inst->reset); DEBUG("rlm_counter: num=%d, last=%c",num,last); diff --git a/src/modules/rlm_eap/eap.c b/src/modules/rlm_eap/eap.c index f0452b43f4..1ece323072 100644 --- a/src/modules/rlm_eap/eap.c +++ b/src/modules/rlm_eap/eap.c @@ -118,7 +118,7 @@ int eap_module_instantiate(rlm_eap_t *inst, eap_module_t **m_inst, eap_type_t nu */ p = mod_name; while (*p) { - *p = tolower(*p); + *p = tolower((uint8_t) *p); p++; } diff --git a/src/modules/rlm_eap/radeapclient.c b/src/modules/rlm_eap/radeapclient.c index cd504a8363..955df1eae0 100644 --- a/src/modules/rlm_eap/radeapclient.c +++ b/src/modules/rlm_eap/radeapclient.c @@ -1959,7 +1959,7 @@ int main(int argc, char **argv) break; case 'r': - if (!isdigit((int) *optarg)) + if (!isdigit((uint8_t) *optarg)) usage(); retries = atoi(optarg); break; @@ -1967,7 +1967,7 @@ int main(int argc, char **argv) do_summary = 1; break; case 't': - if (!isdigit((int) *optarg)) + if (!isdigit((uint8_t) *optarg)) usage(); timeout = atof(optarg); break; @@ -2059,7 +2059,7 @@ int main(int argc, char **argv) /* * Get the request type */ - if (!isdigit((int) argv[2][0])) { + if (!isdigit((uint8_t) argv[2][0])) { packet_code = fr_str2int(rc_request_types, argv[2], -2); if (packet_code == -2) { ERROR("Unrecognised request type \"%s\"\n", argv[2]); diff --git a/src/modules/rlm_expr/rlm_expr.c b/src/modules/rlm_expr/rlm_expr.c index f835800376..a3bf1b4d6a 100644 --- a/src/modules/rlm_expr/rlm_expr.c +++ b/src/modules/rlm_expr/rlm_expr.c @@ -201,7 +201,7 @@ static bool get_number(REQUEST *request, char const **string, int64_t *answer) /* * Look for a number. */ - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; /* * ~1 == 0xff...ffe @@ -296,7 +296,7 @@ static bool get_number(REQUEST *request, char const **string, int64_t *answer) goto done; } - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if ((*p < '0') || (*p > '9')) { RDEBUG2("Not a number at \"%s\"", p); @@ -446,7 +446,7 @@ static bool get_expression(REQUEST *request, char const **string, int64_t *answe if (!get_number(request, &p, &lhs)) return false; redo: - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; /* * A number by itself is OK. @@ -572,7 +572,7 @@ static ssize_t randstr_xlat(UNUSED void *instance, UNUSED REQUEST *request, * But we limit it to 100, because we don't want * utter stupidity. */ - while (isdigit((int) *p)) { + while (isdigit((uint8_t) *p)) { if (number >= 100) { p++; continue; @@ -763,8 +763,8 @@ static ssize_t urlunquote_xlat(UNUSED void *instance, REQUEST *request, /* Is a % char */ /* Don't need \0 check, as it won't be in the hextab */ - if (!(c1 = memchr(hextab, tolower(*++p), 16)) || - !(c2 = memchr(hextab, tolower(*++p), 16))) { + if (!(c1 = memchr(hextab, tolower((uint8_t) *++p), 16)) || + !(c2 = memchr(hextab, tolower((uint8_t) *++p), 16))) { REMARKER(fmt, p - fmt, "None hex char in % sequence"); return -1; } @@ -866,8 +866,8 @@ static ssize_t unescape_xlat(UNUSED void *instance, UNUSED REQUEST *request, /* Is a = char */ - if (!(c1 = memchr(hextab, tolower(*(p + 1)), 16)) || - !(c2 = memchr(hextab, tolower(*(p + 2)), 16))) goto next; + if (!(c1 = memchr(hextab, tolower((uint8_t) *(p + 1)), 16)) || + !(c2 = memchr(hextab, tolower((uint8_t) *(p + 2)), 16))) goto next; c3 = ((c1 - hextab) << 4) + (c2 - hextab); *out++ = c3; @@ -895,7 +895,7 @@ static ssize_t tolower_xlat(UNUSED void *instance, UNUSED REQUEST *request, char for (p = fmt, q = out; *p != '\0'; p++, outlen--) { if (outlen <= 1) break; - *(q++) = tolower((int) *p); + *(q++) = tolower((uint8_t) *p); } *q = '\0'; @@ -919,7 +919,7 @@ static ssize_t toupper_xlat(UNUSED void *instance, UNUSED REQUEST *request, char for (p = fmt, q = out; *p != '\0'; p++, outlen--) { if (outlen <= 1) break; - *(q++) = toupper((int) *p); + *(q++) = toupper((uint8_t) *p); } *q = '\0'; @@ -1149,7 +1149,7 @@ static ssize_t hmac_md5_xlat(UNUSED void *instance, REQUEST *request, data_len = xlat_fmt_to_ref(&data, request, data_ref); if (data_len < 0) return -1; - while (isspace(*p) && p++); + while (isspace((uint8_t) *p) && p++); key_len = xlat_fmt_to_ref(&key, request, p); if (key_len < 0) return -1; @@ -1195,7 +1195,7 @@ static ssize_t hmac_sha1_xlat(UNUSED void *instance, REQUEST *request, data_len = xlat_fmt_to_ref(&data, request, data_ref); if (data_len < 0) return -1; - while (isspace(*p) && p++); + while (isspace((uint8_t) *p) && p++); key_len = xlat_fmt_to_ref(&key, request, p); if (key_len < 0) return -1; @@ -1425,7 +1425,7 @@ static ssize_t explode_xlat(UNUSED void *instance, REQUEST *request, /* * Trim whitespace */ - while (isspace(*p) && p++); + while (isspace((uint8_t) *p) && p++); slen = tmpl_from_attr_substr(&vpt, p, REQUEST_CURRENT, PAIR_LIST_REQUEST, false, false); if (slen <= 0) { @@ -1700,7 +1700,7 @@ static bool parse_pad(REQUEST *request, char const *fmt, *fill = ' '; /* the default */ p = fmt; - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if (*p != '&') { RDEBUG("First argument must be an attribute reference"); @@ -1719,7 +1719,7 @@ static bool parse_pad(REQUEST *request, char const *fmt, p = fmt + slen; - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; length = strtoul(p, &end, 10); if ((length == ULONG_MAX) || (length > 8192)) { @@ -1737,13 +1737,13 @@ static bool parse_pad(REQUEST *request, char const *fmt, * and we must have only ONE fill character. */ if (*p) { - if (!isspace(*p)) { + if (!isspace((uint8_t) *p)) { talloc_free(vpt); RDEBUG("Invalid text found at: %s", p); return false; } - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if (p[1] != '\0') { talloc_free(vpt); diff --git a/src/modules/rlm_json/rlm_json.c b/src/modules/rlm_json/rlm_json.c index af4954de5d..9cf99d832e 100644 --- a/src/modules/rlm_json/rlm_json.c +++ b/src/modules/rlm_json/rlm_json.c @@ -102,11 +102,11 @@ static ssize_t json_encode_xlat(UNUSED void * instance, REQUEST *request, char c p = fmt; - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if (*p == '\0') return -1; while (*p) { - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if (*p == '\0') break; @@ -164,7 +164,7 @@ static ssize_t json_encode_xlat(UNUSED void * instance, REQUEST *request, char c /* Jump forward to next attr */ p += slen; - if (*p != '\0' && !isspace((int)*p)) { + if (*p != '\0' && !isspace((uint8_t)*p)) { REMARKER(fmt, (p - fmt), "Missing whitespace"); goto error; } diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index 33e5a885ca..1d36a837cf 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -827,7 +827,7 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance) case ',': case ';': case ' ': - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if (p == q) continue; buff = talloc_array(inst, char, (q - p) + 1); diff --git a/src/modules/rlm_logintime/timestr.c b/src/modules/rlm_logintime/timestr.c index a1fffc6674..1cd827a16c 100644 --- a/src/modules/rlm_logintime/timestr.c +++ b/src/modules/rlm_logintime/timestr.c @@ -85,7 +85,7 @@ static int hour_fill(char *bitmap, char const *tm) end = -1; if ((p = strchr(tm, '-')) != NULL) { p++; - if (p - tm != 5 || strlen(p) < 4 || !isdigit((int) *p)) + if (p - tm != 5 || strlen(p) < 4 || !isdigit((uint8_t) *p)) return 0; end = 600 * val(p[0]) + 60 * val(p[1]) + atoi(p + 2); } @@ -93,7 +93,7 @@ static int hour_fill(char *bitmap, char const *tm) start = 0; end = DAYMIN - 1; } else { - if (strlen(tm) < 4 || !isdigit((int) *tm)) + if (strlen(tm) < 4 || !isdigit((uint8_t) *tm)) return 0; start = 600 * val(tm[0]) + 60 * val(tm[1]) + atoi(tm + 2); if (end < 0) end = start; @@ -132,7 +132,7 @@ static int day_fill(char *bitmap, char const *tm) int start, end; for (hr = tm; *hr; hr++) - if (isdigit((int) *hr)) + if (isdigit((uint8_t) *hr)) break; if (hr == tm) tm = "Al"; @@ -181,7 +181,7 @@ static int week_fill(char *bitmap, char const *tm) strlcpy(tmp, tm, sizeof(tmp)); for (s = tmp; *s; s++) - if (isupper(*s)) *s = tolower(*s); + if (isupper((uint8_t) *s)) *s = tolower((uint8_t) *s); s = strtok(tmp, ",|"); while (s) { diff --git a/src/modules/rlm_mschap/rlm_mschap.c b/src/modules/rlm_mschap/rlm_mschap.c index 25bcd9c44e..00ab90d994 100644 --- a/src/modules/rlm_mschap/rlm_mschap.c +++ b/src/modules/rlm_mschap/rlm_mschap.c @@ -489,7 +489,7 @@ static ssize_t mschap_xlat(void *instance, REQUEST *request, if ((*p == '\0') || (outlen <= 32)) return 0; - while (isspace(*p)) p++; + while (isspace((uint8_t) *p)) p++; if (mschap_ntpwdhash(buffer, p) < 0) { REDEBUG("Failed generating NT-Password"); @@ -512,7 +512,7 @@ static ssize_t mschap_xlat(void *instance, REQUEST *request, if ((*p == '\0') || (outlen <= 32)) return 0; - while (isspace(*p)) p++; + while (isspace((uint8_t) *p)) p++; smbdes_lmpwdhash(p, buffer); fr_bin2hex(out, buffer, LM_DIGEST_LENGTH); diff --git a/src/modules/rlm_mschap/smbdes.c b/src/modules/rlm_mschap/smbdes.c index 12e75a0000..d80de343c3 100644 --- a/src/modules/rlm_mschap/smbdes.c +++ b/src/modules/rlm_mschap/smbdes.c @@ -323,7 +323,7 @@ void smbdes_lmpwdhash(char const *password, uint8_t *lmhash) memset(p14, 0, sizeof(p14)); for (i = 0; i < 14 && password[i]; i++) { - p14[i] = toupper((int) password[i]); + p14[i] = toupper((uint8_t) password[i]); } smbhash(lmhash, sp8, p14); diff --git a/src/modules/rlm_rest/rest.c b/src/modules/rlm_rest/rest.c index fcb3fd11fc..e43785f9a7 100644 --- a/src/modules/rlm_rest/rest.c +++ b/src/modules/rlm_rest/rest.c @@ -1099,7 +1099,7 @@ static int rest_decode_post(UNUSED rlm_rest_t *instance, UNUSED rlm_rest_section /* * Empty response? */ - while (isspace(*p)) p++; + while (isspace((uint8_t) *p)) p++; if (*p == '\0') return 0; while (((q = strchr(p, '=')) != NULL) && (count < REST_BODY_MAX_ATTRS)) { @@ -1563,7 +1563,7 @@ static int rest_decode_json(rlm_rest_t *instance, rlm_rest_section_t *section, /* * Empty response? */ - while (isspace(*p)) p++; + while (isspace((uint8_t) *p)) p++; if (*p == '\0') return 0; json = json_tokener_parse(p); diff --git a/src/modules/rlm_rest/rlm_rest.c b/src/modules/rlm_rest/rlm_rest.c index 1337ae5425..72286b71e6 100644 --- a/src/modules/rlm_rest/rlm_rest.c +++ b/src/modules/rlm_rest/rlm_rest.c @@ -254,7 +254,7 @@ static ssize_t rest_xlat(void *instance, REQUEST *request, /* * Trim whitespace */ - while (isspace(*p) && p++); + while (isspace((uint8_t) *p) && p++); /* * Unescape parts of xlat'd URI, this allows REST servers to be specified by diff --git a/src/modules/rlm_sql/drivers/rlm_sql_mongo/rlm_sql_mongo.c b/src/modules/rlm_sql/drivers/rlm_sql_mongo/rlm_sql_mongo.c index a45dd65473..f40f18af3c 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_mongo/rlm_sql_mongo.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_mongo/rlm_sql_mongo.c @@ -243,7 +243,7 @@ static CC_HINT(nonnull) sql_rcode_t sql_query(rlm_sql_handle_t *handle, rlm_sql_ * We parse the string to see what's up. */ p = query; - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if (strncmp(p, "db.", 3) != 0) { ERROR("rlm_sql_mongo: Invalid query - must start with 'db.'"); @@ -284,9 +284,9 @@ static CC_HINT(nonnull) sql_rcode_t sql_query(rlm_sql_handle_t *handle, rlm_sql_ * Allow whitespace after the command name, and * before the bracket. */ - if (isspace((int) *p)) { + if (isspace((uint8_t) *p)) { *ptr = '\0'; - while (*p && isspace((int) *p)) p++; + while (*p && isspace((uint8_t) *p)) p++; if (*p != '(') { ERROR("rlm_sql_mongo: Invalid query - no starting '('"); diff --git a/src/modules/rlm_sql_map/rlm_sql_map.c b/src/modules/rlm_sql_map/rlm_sql_map.c index e720c8e7aa..f0da7aa3e5 100644 --- a/src/modules/rlm_sql_map/rlm_sql_map.c +++ b/src/modules/rlm_sql_map/rlm_sql_map.c @@ -315,7 +315,7 @@ static int mod_bootstrap(CONF_SECTION *conf, void *instance) return -1; } - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if ((strncasecmp(p, "insert", 6) == 0) || (strncasecmp(p, "update", 6) == 0) || diff --git a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c index 26aded7a7c..5987ae6263 100644 --- a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c +++ b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c @@ -124,12 +124,12 @@ static int find_next_reset(rlm_sqlcounter_t *inst, REQUEST *request, time_t time /* * Reset every N hours, days, weeks, months. */ - if (isdigit((int) inst->reset[0])){ + if (isdigit((uint8_t) inst->reset[0])){ len = strlen(inst->reset); if (len == 0) return -1; last = inst->reset[len - 1]; - if (!isalpha((int) last)) { + if (!isalpha((uint8_t) last)) { last = 'd'; } @@ -212,12 +212,12 @@ static int find_prev_reset(rlm_sqlcounter_t *inst, time_t timeval) rad_assert(inst->reset != NULL); - if (isdigit((int) inst->reset[0])){ + if (isdigit((uint8_t) inst->reset[0])){ len = strlen(inst->reset); if (len == 0) return -1; last = inst->reset[len - 1]; - if (!isalpha((int) last)) + if (!isalpha((uint8_t) last)) last = 'd'; num = atoi(inst->reset); DEBUG("rlm_sqlcounter: num=%d, last=%c",num,last); diff --git a/src/modules/rlm_unpack/rlm_unpack.c b/src/modules/rlm_unpack/rlm_unpack.c index 93979818ba..dfdc81a809 100644 --- a/src/modules/rlm_unpack/rlm_unpack.c +++ b/src/modules/rlm_unpack/rlm_unpack.c @@ -58,11 +58,11 @@ static ssize_t unpack_xlat(UNUSED void *instance, REQUEST *request, char const * strlcpy(buffer, fmt, sizeof(buffer)); p = buffer; - while (isspace((int) *p)) p++; /* skip leading spaces */ + while (isspace((uint8_t) *p)) p++; /* skip leading spaces */ data_name = p; - while (*p && !isspace((int) *p)) p++; + while (*p && !isspace((uint8_t) *p)) p++; if (!*p) { error: @@ -72,20 +72,20 @@ static ssize_t unpack_xlat(UNUSED void *instance, REQUEST *request, char const * return -1; } - while (isspace((int) *p)) *(p++) = '\0'; + while (isspace((uint8_t) *p)) *(p++) = '\0'; if (!*p) GOTO_ERROR; data_size = p; - while (*p && !isspace((int) *p)) p++; + while (*p && !isspace((uint8_t) *p)) p++; if (!*p) GOTO_ERROR; - while (isspace((int) *p)) *(p++) = '\0'; + while (isspace((uint8_t) *p)) *(p++) = '\0'; if (!*p) GOTO_ERROR; data_type = p; - while (*p && !isspace((int) *p)) p++; + while (*p && !isspace((uint8_t) *p)) p++; if (*p) GOTO_ERROR; /* anything after the type is an error */ /* @@ -287,7 +287,7 @@ static ssize_t substring_xlat(UNUSED void *instance, REQUEST *request, /* * Trim whitespace */ - while (isspace(*p) && p++); + while (isspace((uint8_t) *p) && p++); /* * Find numeric parameters at the end. diff --git a/src/modules/rlm_yubikey/rlm_yubikey.c b/src/modules/rlm_yubikey/rlm_yubikey.c index 1908e9d28c..83b76558ca 100644 --- a/src/modules/rlm_yubikey/rlm_yubikey.c +++ b/src/modules/rlm_yubikey/rlm_yubikey.c @@ -88,8 +88,8 @@ static ssize_t modhex2hex(char const *modhex, uint8_t *hex, size_t len) if (modhex[(i << 1) + 1] == '\0') return -1; - if (!(c1 = memchr(modhextab, tolower((int) modhex[i << 1]), 16)) || - !(c2 = memchr(modhextab, tolower((int) modhex[(i << 1) + 1]), 16))) + if (!(c1 = memchr(modhextab, tolower((uint8_t) modhex[i << 1]), 16)) || + !(c2 = memchr(modhextab, tolower((uint8_t) modhex[(i << 1) + 1]), 16))) return -1; hex[i] = hextab[c1 - modhextab];