From: Alan T. DeKok Date: Mon, 16 Jan 2023 13:05:54 +0000 (-0500) Subject: ctype macros should take explicitly unsigned input X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40d48f71edf1e956477214e8838d60d96d9fb72c;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) --- diff --git a/scripts/build/dlopen.c b/scripts/build/dlopen.c index 9775aaa6aca..622fa44fe39 100644 --- a/scripts/build/dlopen.c +++ b/scripts/build/dlopen.c @@ -173,7 +173,7 @@ static void *check_path(char *filename, char const *name, size_t namelen, void *handle; p = path; - while (isspace((int) *p)) p++; /* GNU make is fanatical about spaces */ + while (isspace((uint8_t) *p)) p++; /* GNU make is fanatical about spaces */ len = strlen(p); if ((len + 1 + namelen + 1) > PATH_MAX) return NULL; @@ -525,7 +525,7 @@ static char *make_dlsym(__attribute__((unused)) char const *nm, __attribute__((u if (!lib) return NULL; p = argv[1]; - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; symbol = dlsym(lib->handle, p); if (!symbol) return NULL; @@ -602,8 +602,8 @@ static void ad_have_feature(char const *symbol) *p = '\0'; /* gets strcmp'd later */ for (p = def->name + 5; *p != '\0'; p++) { - if (islower((int) *p)) { - *p = toupper((int) *p); + if (islower((uint8_t) *p)) { + *p = toupper((uint8_t) *p); } else if ((*p == '/') || (*p == '.')) { *p = '_'; @@ -672,7 +672,7 @@ static void ad_update_variable(char const *name, char *value) p = strstr(old, value); if (p) { - if (!p[value_len] || isspace((int) p[value_len])) { + if (!p[value_len] || isspace((uint8_t) p[value_len])) { gmk_free(old); return; } @@ -800,7 +800,7 @@ static char *make_ad_search_libs(__attribute__((unused)) char const *nm, unsigne * Get the symbol name */ name = argv[0]; - while (isspace((int) *name)) name++; + while (isspace((uint8_t) *name)) name++; DEBUG("Searching for symbol %s", name); @@ -831,7 +831,7 @@ static char *make_ad_search_libs(__attribute__((unused)) char const *nm, unsigne */ p = argv[i]; while (p < r) { - while (isspace((int) *p)) p++; + while (isspace((uint8_t) *p)) p++; if ((p[0] == '-') && (p[1] == 'L')) { has_dash_l = true; @@ -840,14 +840,14 @@ static char *make_ad_search_libs(__attribute__((unused)) char const *nm, unsigne * -L /path/to/foo is OK */ q = p + 2; - while (isspace((int) *q)) q++; + while (isspace((uint8_t) *q)) q++; /* * @todo - deal with * quotes and backslashes * in file names. */ - while (*q && !isspace((int) *q)) q++; + while (*q && !isspace((uint8_t) *q)) q++; *q = '\0'; @@ -867,7 +867,7 @@ static char *make_ad_search_libs(__attribute__((unused)) char const *nm, unsigne /* * The argument isn't -L foo, skip it. */ - while (*p && !isspace((int) *p)) p++; + while (*p && !isspace((uint8_t) *p)) p++; } /* @@ -1012,7 +1012,7 @@ static char *make_ad_dump_defines(__attribute__((unused)) char const *nm, unsign FILE *fp; unsigned int i; - if ((argc == 0) || !*argv[0] || isspace((int) *argv[0])) { + if ((argc == 0) || !*argv[0] || isspace((uint8_t) *argv[0])) { /* * Print Makefile rules to redefine the variables we've created. */ @@ -1262,7 +1262,7 @@ static char *next_word(char **in) p = *in; - while (*p && !isspace((int) *p)) p++; + while (*p && !isspace((uint8_t) *p)) p++; if (!*p) { *in = NULL; } else { diff --git a/src/bin/collectd.c b/src/bin/collectd.c index 3295f50e7d6..495a6d839f2 100644 --- a/src/bin/collectd.c +++ b/src/bin/collectd.c @@ -265,7 +265,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/bin/dhcpclient.c b/src/bin/dhcpclient.c index e9e060e86fd..30b969ad0cf 100644 --- a/src/bin/dhcpclient.c +++ b/src/bin/dhcpclient.c @@ -582,7 +582,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; @@ -654,7 +654,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_table_value_by_str(request_types, argv[2], -2); if (packet_code == -2) { ERROR("Unknown packet type: %s", argv[2]); diff --git a/src/bin/radclient.c b/src/bin/radclient.c index ef0f65eb5a5..8927ef0b127 100644 --- a/src/bin/radclient.c +++ b/src/bin/radclient.c @@ -1467,7 +1467,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); @@ -1554,7 +1554,7 @@ int main(int argc, char **argv) break; case 'i': - if (!isdigit((int) *optarg)) + if (!isdigit((uint8_t) *optarg)) usage(); last_used_id = atoi(optarg); if ((last_used_id < 0) || (last_used_id > 255)) { @@ -1594,7 +1594,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; @@ -1699,7 +1699,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_table_value_by_str(fr_request_types, argv[2], -2); if (packet_code == -2) { ERROR("Unrecognised request type \"%s\"", argv[2]); diff --git a/src/bin/radsnmp.c b/src/bin/radsnmp.c index 2854b7dae9c..55fd6192ec7 100644 --- a/src/bin/radsnmp.c +++ b/src/bin/radsnmp.c @@ -976,7 +976,7 @@ int main(int argc, char **argv) break; case 'r': - if (!isdigit((int) *optarg)) usage(); + if (!isdigit((uint8_t) *optarg)) usage(); conf->retries = atoi(optarg); if ((conf->retries == 0) || (conf->retries > 1000)) usage(); break; @@ -1065,7 +1065,7 @@ int main(int argc, char **argv) /* * Get the request type */ - if (!isdigit((int) argv[2][0])) { + if (!isdigit((uint8_t) argv[2][0])) { int code; code = fr_table_value_by_str(fr_request_types, argv[2], -1); diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index b922632e8ae..adc8e21a868 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -567,14 +567,14 @@ static ssize_t hex_to_bin(uint8_t *out, size_t outlen, char *in, size_t inlen) if (!*p) break; - c1 = memchr(hextab, tolower((int) *p++), sizeof(hextab)); + c1 = memchr(hextab, tolower((uint8_t) *p++), sizeof(hextab)); if (!c1) { bad_input: fr_strerror_printf("Invalid hex data starting at \"%s\"", p); return -(p - in); } - c2 = memchr(hextab, tolower((int)*p++), sizeof(hextab)); + c2 = memchr(hextab, tolower((uint8_t)*p++), sizeof(hextab)); if (!c2) goto bad_input; *out_p++ = ((c1 - hextab) << 4) + (c2 - hextab); @@ -588,7 +588,7 @@ static ssize_t encode_data(char *p, uint8_t *output, size_t outlen) { ssize_t slen; - if (!isspace((int) *p)) { + if (!isspace((uint8_t) *p)) { ERROR("Invalid character following attribute definition"); return 0; } @@ -1376,7 +1376,7 @@ static size_t command_radmin_add(command_result_t *result, command_file_ctx_t *c name = p; fr_skip_whitespace(p); - if (isspace(*p)) { + if (isspace((uint8_t) *p)) { *p = '\0'; p++; } diff --git a/src/lib/ldap/filter.c b/src/lib/ldap/filter.c index c22f401ad06..afc33032cea 100644 --- a/src/lib/ldap/filter.c +++ b/src/lib/ldap/filter.c @@ -491,9 +491,9 @@ static bool ldap_filter_node_eval(ldap_filter_t *node, fr_ldap_connection_t *con continue; } if (skip) { - while ((tolower(*t) != tolower(*v)) && (v <= v_end)) v++; + while ((tolower((uint8_t) *t) != tolower((uint8_t) *v)) && (v <= v_end)) v++; } - if (tolower(*t) != tolower(*v)) break; + if (tolower((uint8_t) *t) != tolower((uint8_t) *v)) break; skip = false; t++; v++; diff --git a/src/lib/server/cf_file.c b/src/lib/server/cf_file.c index 5e124c04840..c7dc8d2e6af 100644 --- a/src/lib/server/cf_file.c +++ b/src/lib/server/cf_file.c @@ -869,7 +869,7 @@ static int process_include(cf_stack_t *stack, CONF_SECTION *parent, char const * * Grab all of the non-whitespace text. */ value = ptr; - while (*ptr && !isspace((int) *ptr)) ptr++; + while (*ptr && !isspace((uint8_t) *ptr)) ptr++; /* * We're OK with whitespace after the filename. @@ -1066,8 +1066,8 @@ static int process_include(cf_stack_t *stack, CONF_SECTION *parent, char const * * 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; @@ -1333,7 +1333,7 @@ static ssize_t fr_skip_condition(char const *start, char const *end, bool const * Keep parsing the condition until we hit EOS or EOL. */ while ((end && (p < end)) || *p) { - if (isspace((int) *p)) { + if (isspace((uint8_t) *p)) { p++; continue; } @@ -1595,7 +1595,7 @@ static CONF_ITEM *process_if(cf_stack_t *stack) name2 = buff[2]; while (slen > 0) { - if (!isspace((int) buff[2][slen])) break; + if (!isspace((uint8_t) buff[2][slen])) break; buff[2][slen] = '\0'; slen--; @@ -2119,7 +2119,7 @@ static int parse_input(cf_stack_t *stack) return -1; } - } else if ((name1_token == T_BARE_WORD) && isalpha((int) *buff[1])) { + } else if ((name1_token == T_BARE_WORD) && isalpha((uint8_t) *buff[1])) { fr_type_t type; /* @@ -2219,7 +2219,7 @@ check_for_eol: * it, so oh well. */ if ((*ptr == '"') || (*ptr == '`') || (*ptr == '\'') || ((*ptr == '&') && (ptr[1] != '=')) || - ((*((uint8_t const *) ptr) & 0x80) != 0) || isalpha((int) *ptr) || isdigit((int) *ptr)) { + ((*((uint8_t const *) ptr) & 0x80) != 0) || isalpha((uint8_t) *ptr) || isdigit((uint8_t) *ptr)) { if (cf_get_token(parent, &ptr, &name2_token, buff[2], stack->bufsize, frame->filename, frame->lineno) < 0) { return -1; diff --git a/src/lib/server/command.c b/src/lib/server/command.c index fcb6790fbdc..0dbd54ae80a 100644 --- a/src/lib/server/command.c +++ b/src/lib/server/command.c @@ -214,8 +214,8 @@ static bool fr_command_valid_syntax(fr_cmd_argv_t *argv) } for (p = argv->name; *p != '\0'; p++) { - if (isupper((int) *p)) uppercase = true; - if (islower((int) *p)) lowercase = true; + if (isupper((uint8_t) *p)) uppercase = true; + if (islower((uint8_t) *p)) lowercase = true; } /* @@ -1361,7 +1361,7 @@ int fr_command_tab_expand(TALLOC_CTX *ctx, fr_cmd_t *head, fr_cmd_info_t *info, p++; \ q++; \ } } while (0) -#define MATCHED_NAME ((!*p || isspace((int) *p)) && !*q) +#define MATCHED_NAME ((!*p || isspace((uint8_t) *p)) && !*q) #define TOO_FAR (*p && (*q > *p)) #define MATCHED_START ((text + start) >= word) && ((text + start) <= p) @@ -2546,7 +2546,7 @@ static int expand_syntax(fr_cmd_t *cmd, fr_cmd_info_t *info, fr_cmd_argv_t *argv * Tell the caller the * full name. */ - if (!*p || (isspace((int) *p))) { + if (!*p || (isspace((uint8_t) *p))) { expand_name: expansions[count] = strdup(argv->name); count++; @@ -2624,7 +2624,7 @@ static int expand_syntax(fr_cmd_t *cmd, fr_cmd_info_t *info, fr_cmd_argv_t *argv * matching all of the name. The input is a * PARTIAL match. Go fill it in. */ - if (!*p || isspace((int) *p)) { + if (!*p || isspace((uint8_t) *p)) { goto expand_name; } @@ -2699,7 +2699,7 @@ int fr_command_complete(fr_cmd_t *head, char const *text, int start, * Matched all of the input to * part of cmd->name. */ - if (!*p || isspace((int) *p)) { + if (!*p || isspace((uint8_t) *p)) { expansions[count] = strdup(cmd->name); count++; } diff --git a/src/lib/server/cond_tokenize.c b/src/lib/server/cond_tokenize.c index 3e2b351581a..c487b158cba 100644 --- a/src/lib/server/cond_tokenize.c +++ b/src/lib/server/cond_tokenize.c @@ -696,7 +696,7 @@ static int cond_normalise(TALLOC_CTX *ctx, fr_token_t lhs_type, fr_cond_t **c_ou 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/lib/server/dl_module.c b/src/lib/server/dl_module.c index 61511de95b0..f839df373d3 100644 --- a/src/lib/server/dl_module.c +++ b/src/lib/server/dl_module.c @@ -402,7 +402,7 @@ dl_module_t const *dl_module(dl_module_t const *parent, char const *name, dl_mod if (!module_name) return NULL; - for (p = module_name, q = p + talloc_array_length(p) - 1; p < q; p++) *p = tolower(*p); + for (p = module_name, q = p + talloc_array_length(p) - 1; p < q; p++) *p = tolower((uint8_t) *p); /* * If the module's already been loaded, increment the reference count. diff --git a/src/lib/server/exec.c b/src/lib/server/exec.c index 0a9d52e9d2a..128928a7e36 100644 --- a/src/lib/server/exec.c +++ b/src/lib/server/exec.c @@ -123,11 +123,11 @@ static CC_HINT(nonnull(1,3,4,5)) int exec_pair_to_env(char **env_p, size_t env_l * for the first char. */ p = fr_sbuff_current(&env_m[i]); - if (isdigit((int)*p)) *p++ = '_'; + if (isdigit((uint8_t)*p)) *p++ = '_'; for (; p < fr_sbuff_current(&sbuff); p++) { - if (isalpha((int)*p)) *p = toupper(*p); + if (isalpha((uint8_t)*p)) *p = toupper((uint8_t) *p); else if (*p == '-') *p = '_'; - else if (isdigit((int)*p)) continue; + else if (isdigit((uint8_t)*p)) continue; else *p = '_'; } diff --git a/src/lib/server/exec_legacy.c b/src/lib/server/exec_legacy.c index af90dace57e..075c9eac65d 100644 --- a/src/lib/server/exec_legacy.c +++ b/src/lib/server/exec_legacy.c @@ -63,8 +63,8 @@ static void exec_pair_to_env_legacy(request_t *request, fr_pair_list_t *input_pa 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/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index d6a89190470..c1234bddafc 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -454,8 +454,8 @@ size_t tmpl_pair_list_name(tmpl_pair_list_t *out, char const *name, tmpl_pair_li { 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++; if (!fr_dict_attr_allowed_chars[(uint8_t) *d]) { *out = def; @@ -5083,7 +5083,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t i *type = T_INVALID; if (castda) *castda = NULL; - while (isspace((int) *p) && (p < end)) p++; + while (isspace((uint8_t) *p) && (p < end)) p++; if (p >= end) return p - in; if (*p == '<') { @@ -5099,7 +5099,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t i p++; fr_skip_whitespace(p); - for (q = p; *q && !isspace((int) *q) && (*q != '>'); q++) { + for (q = p; *q && !isspace((uint8_t) *q) && (*q != '>'); q++) { /* nothing */ } @@ -5320,7 +5320,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *in, size_t i * Allow *most* things. But stop on spaces and special characters. */ while (*p) { - if (isspace((int) *p)) { + if (isspace((uint8_t) *p)) { break; } diff --git a/src/lib/tls/session.c b/src/lib/tls/session.c index e4c2f1fcf7d..c2b5096531e 100644 --- a/src/lib/tls/session.c +++ b/src/lib/tls/session.c @@ -292,7 +292,7 @@ static bool session_psk_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; } @@ -1163,7 +1163,7 @@ static unlang_action_t tls_session_async_handshake_done_round(UNUSED rlm_rcode_t * Seems to print info in a tabular format. */ while (*p != '\0') { - if (isspace(*p)) { + if (isspace((uint8_t) *p)) { *q++ = *p; fr_skip_whitespace(p); continue; diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index 2c42df18d07..703a44df818 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -3252,7 +3252,7 @@ static unlang_t *compile_timeout(unlang_t *parent, unlang_compile_t *unlang_ctx, token = cf_section_name2_quote(cs); - if ((token == T_BARE_WORD) && isdigit((int) *name2)) { + if ((token == T_BARE_WORD) && isdigit((uint8_t) *name2)) { if (fr_time_delta_from_str(&timeout, name2, strlen(name2), FR_TIME_RES_SEC) < 0) { cf_log_err(cs, "Failed parsing time delta %s - %s", name2, fr_strerror()); diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index 6392185953c..a79a87639da 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -2885,7 +2885,7 @@ static xlat_action_t xlat_func_randstr(TALLOC_CTX *ctx, fr_dcursor_t *out, * We limit it to REPETITION_MAX, because we don't want * utter stupidity. */ - if (isdigit((int) *p)) { + if (isdigit((uint8_t) *p)) { reps = strtol(p, &endptr, 10); if (reps > REPETITION_MAX) reps = REPETITION_MAX; outlen += reps; @@ -2905,7 +2905,7 @@ static xlat_action_t xlat_func_randstr(TALLOC_CTX *ctx, fr_dcursor_t *out, while (p < end) { size_t i; - if (isdigit((int) *p)) { + if (isdigit((uint8_t) *p)) { reps = strtol(p, &endptr, 10); if (reps > REPETITION_MAX) { reps = REPETITION_MAX; @@ -3491,7 +3491,7 @@ static xlat_action_t xlat_change_case(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out, end = p + vb->vb_length; while (p < end) { - *(p) = upper ? toupper ((int) *(p)) : tolower((int) *(p)); + *(p) = upper ? toupper ((int) *(p)) : tolower((uint8_t) *(p)); p++; } @@ -3682,8 +3682,8 @@ static xlat_action_t xlat_func_urlunquote(TALLOC_CTX *ctx, fr_dcursor_t *out, /* 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(in_head->vb_strvalue, p - in_head->vb_strvalue, "Non-hex char in %% sequence"); talloc_free(vb); @@ -3876,7 +3876,7 @@ static int xlat_protocol_register(fr_dict_t const *dict) strlcpy(name, fr_dict_root(dict)->name, sizeof(name)); for (p = name; *p != '\0'; p++) { - *p = tolower((int) *p); + *p = tolower((uint8_t) *p); } /* diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index c19b47e61d3..c078cf177fa 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -1841,7 +1841,7 @@ static const int precedence[T_TOKEN_LAST] = { #define fr_sbuff_skip_whitespace(_x) \ do { \ - while (isspace((int) fr_sbuff_char(_x, '\0'))) fr_sbuff_advance(_x, 1); \ + while (isspace((uint8_t) fr_sbuff_char(_x, '\0'))) fr_sbuff_advance(_x, 1); \ } while (0) static ssize_t tokenize_expression(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in, diff --git a/src/lib/util/dict_tokenize.c b/src/lib/util/dict_tokenize.c index e8d499568e1..b4d8193d3da 100644 --- a/src/lib/util/dict_tokenize.c +++ b/src/lib/util/dict_tokenize.c @@ -125,7 +125,7 @@ static int dict_read_sscanf_i(unsigned int *pvalue, char const *str) if (*str == '.') break; - c = memchr(tab, tolower((int)*str), base); + c = memchr(tab, tolower((uint8_t)*str), base); if (!c) return 0; ret *= base; @@ -1562,9 +1562,9 @@ static int dict_read_parse_format(char const *format, int *ptype, int *plength, 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("Invalid format for VENDOR. Expected text like '1,1', got '%s'", p); diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index c622d024e6c..89030f86999 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -3116,7 +3116,7 @@ int dict_dlopen(fr_dict_t *dict, char const *name) if (!name) return 0; module_name = talloc_typed_asprintf(NULL, "libfreeradius-%s", name); - for (p = module_name, q = p + talloc_array_length(p) - 1; p < q; p++) *p = tolower(*p); + for (p = module_name, q = p + talloc_array_length(p) - 1; p < q; p++) *p = tolower((uint8_t) *p); /* * Pass in dict as the uctx so that we can get at it in diff --git a/src/lib/util/getaddrinfo.c b/src/lib/util/getaddrinfo.c index 182e8b858a4..56294125bc1 100644 --- a/src/lib/util/getaddrinfo.c +++ b/src/lib/util/getaddrinfo.c @@ -289,7 +289,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/util/hash.c b/src/lib/util/hash.c index 79e0a2c4bd5..6ceeaa4f74e 100644 --- a/src/lib/util/hash.c +++ b/src/lib/util/hash.c @@ -877,7 +877,7 @@ uint32_t fr_hash_case_string(char const *p) while (*p) { hash *= FNV_MAGIC_PRIME; - hash ^= (uint32_t) (tolower(*p++)); + hash ^= (uint32_t) (tolower((uint8_t) *p++)); } return hash; diff --git a/src/lib/util/inet.c b/src/lib/util/inet.c index 7277dfa3697..3086f5832a8 100644 --- a/src/lib/util/inet.c +++ b/src/lib/util/inet.c @@ -479,7 +479,7 @@ int fr_inet_pton4(fr_ipaddr_t *out, char const *value, ssize_t inlen, bool resol memset(out, 0, sizeof(*out)); end = value + inlen; - while ((value < end) && isspace((int) *value)) value++; + while ((value < end) && isspace((uint8_t) *value)) value++; if (value == end) { fr_strerror_const("Empty IPv4 address string is invalid"); return -1; @@ -630,7 +630,7 @@ int fr_inet_pton6(fr_ipaddr_t *out, char const *value, ssize_t inlen, bool resol if (inlen < 0) inlen = strlen(value); end = value + inlen; - while ((value < end) && isspace((int) *value)) value++; + while ((value < end) && isspace((uint8_t) *value)) value++; if (value == end) { fr_strerror_const("Empty IPv6 address string is invalid"); return -1; @@ -770,7 +770,7 @@ int fr_inet_pton(fr_ipaddr_t *out, char const *value, ssize_t inlen, int af, boo char const *end; end = value + inlen; - while ((value < end) && isspace((int) *value)) value++; + while ((value < end) && isspace((uint8_t) *value)) value++; if (value == end) { fr_strerror_const("Empty IPv4 address string is invalid"); return -1; @@ -1125,7 +1125,7 @@ uint8_t *fr_inet_ifid_pton(uint8_t out[static 8], char const *ifid_str) 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; /* diff --git a/src/lib/util/misc.c b/src/lib/util/misc.c index c00ffb382db..647e465423e 100644 --- a/src/lib/util/misc.c +++ b/src/lib/util/misc.c @@ -217,7 +217,7 @@ char *fr_trim(char const *str, size_t size) if (!str || !size) return NULL; memcpy(&q, &str, sizeof(q)); - for (q = q + size; q > str && isspace(*q); q--); + for (q = q + size; q > str && isspace((uint8_t) *q); q--); return q; } diff --git a/src/lib/util/misc.h b/src/lib/util/misc.h index 31ea5a6161c..033faa4c37f 100644 --- a/src/lib/util/misc.h +++ b/src/lib/util/misc.h @@ -56,26 +56,26 @@ void fr_talloc_verify_cb(const void *ptr, int depth, * * @param[in,out] _p string to skip over. */ -#define fr_skip_whitespace(_p) while(isspace((int)*(_p))) _p++ +#define fr_skip_whitespace(_p) while(isspace((uint8_t)*(_p))) _p++ /** Skip whitespace, stopping at end ('\\t', '\\n', '\\v', '\\f', '\\r', ' ') * * @param[in,out] _p string to skip over. * @param[in] _e pointer to end of string. */ -#define fr_bskip_whitespace(_p, _e) while((_p < _e) && isspace((int)*(_p))) _p++ +#define fr_bskip_whitespace(_p, _e) while((_p < _e) && isspace((uint8_t)*(_p))) _p++ /** Skip everything that's not whitespace ('\\t', '\\n', '\\v', '\\f', '\\r', ' ') * * @param[in,out] _p string to skip over. */ -#define fr_skip_not_whitespace(_p) while(*_p && !isspace((int)*(_p))) _p++ +#define fr_skip_not_whitespace(_p) while(*_p && !isspace((uint8_t)*(_p))) _p++ /** Zero out any whitespace with nul bytes * * @param[in,out] _p string to process */ -#define fr_zero_whitespace(_p) while (isspace((int) *_p)) *(_p++) = '\0' +#define fr_zero_whitespace(_p) while (isspace((uint8_t) *_p)) *(_p++) = '\0' /** Check whether the string is all whitespace * @@ -89,7 +89,7 @@ static inline bool is_whitespace(char const *value) if (*value == '\0') return false; /* clang analyzer doesn't seem to know what isspace does */ #endif do { - if (!isspace(*value)) return false; + if (!isspace((uint8_t) *value)) return false; } while (*++value); return true; @@ -131,7 +131,7 @@ static inline bool is_integer(char const *value) if (*value == '\0') return false; /* clang analyzer doesn't seem to know what isdigit does */ #endif do { - if (!isdigit(*value)) return false; + if (!isdigit((uint8_t) *value)) return false; } while (*++value); return true; diff --git a/src/lib/util/pair_tokenize.c b/src/lib/util/pair_tokenize.c index d2c9fe0e348..e91f43eaa0e 100644 --- a/src/lib/util/pair_tokenize.c +++ b/src/lib/util/pair_tokenize.c @@ -201,7 +201,7 @@ static ssize_t fr_pair_afrom_str(fr_pair_ctx_t *pair_ctx, char const *start, cha return -(in - start); } - while ((isspace((int) *p)) && (p < end)) p++; + while ((isspace((uint8_t) *p)) && (p < end)) p++; if (p >= end) { fr_strerror_const("No operator found in the input buffer"); @@ -218,7 +218,7 @@ static ssize_t fr_pair_afrom_str(fr_pair_ctx_t *pair_ctx, char const *start, cha } p += slen; - while ((isspace((int) *p)) && (p < end)) p++; + while ((isspace((uint8_t) *p)) && (p < end)) p++; if (p >= end) { fr_strerror_const("No value found in the input buffer"); @@ -246,7 +246,7 @@ static ssize_t fr_pair_afrom_str(fr_pair_ctx_t *pair_ctx, char const *start, cha /* * Skip bare words, but end at comma or end-of-buffer. */ - while (!isspace((int) *p) && (*p != ',') && (p < end)) p++; + while (!isspace((uint8_t) *p) && (*p != ',') && (p < end)) p++; value_len = p - value; } @@ -379,7 +379,7 @@ ssize_t fr_pair_ctx_afrom_str(fr_pair_ctx_t *pair_ctx, char const *in, size_t in ssize_t slen; fr_dict_attr_t const *da; - while (isspace((int) *p) && (p < end)) p++; + while (isspace((uint8_t) *p) && (p < end)) p++; if (p >= end) return end - in; /* diff --git a/src/lib/util/print.c b/src/lib/util/print.c index 78404f45bfd..8dfb41abd63 100644 --- a/src/lib/util/print.c +++ b/src/lib/util/print.c @@ -494,7 +494,7 @@ char *fr_vasprintf(TALLOC_CTX *ctx, char const *fmt, va_list ap) /* * Check for parameter field */ - for (q = p; isdigit(*q); q++); + for (q = p; isdigit((uint8_t) *q); q++); if ((q != p) && (*q == '$')) { p = q + 1; } @@ -536,7 +536,7 @@ char *fr_vasprintf(TALLOC_CTX *ctx, char const *fmt, va_list ap) (void) va_arg(ap_q, int); p++; } else { - for (q = p; isdigit(*q); q++); + for (q = p; isdigit((uint8_t) *q); q++); p = q; } diff --git a/src/lib/util/sbuff.c b/src/lib/util/sbuff.c index 6b5e53ee83f..b2c23a20f65 100644 --- a/src/lib/util/sbuff.c +++ b/src/lib/util/sbuff.c @@ -1172,8 +1172,8 @@ fr_slen_t fr_sbuff_out_##_name(fr_sbuff_parse_error_t *err, _type *out, fr_sbuff } \ if ((errno == ERANGE) && (num == LLONG_MIN)) goto underflow; \ if (no_trailing && (((a_end = in->p + (end - buff)) + 1) < in->end)) { \ - if (isdigit(*a_end) || (((_base > 10) || ((_base == 0) && (len > 2) && (buff[0] == '0') && (buff[1] == 'x'))) && \ - ((tolower(*a_end) >= 'a') && (tolower(*a_end) <= 'f')))) { \ + if (isdigit((uint8_t) *a_end) || (((_base > 10) || ((_base == 0) && (len > 2) && (buff[0] == '0') && (buff[1] == 'x'))) && \ + ((tolower((uint8_t) *a_end) >= 'a') && (tolower((uint8_t) *a_end) <= 'f')))) { \ if (err) *err = FR_SBUFF_PARSE_ERROR_TRAILING; \ *out = (_type)(_max); \ FR_SBUFF_ERROR_RETURN(&our_in); \ @@ -1236,8 +1236,8 @@ fr_slen_t fr_sbuff_out_##_name(fr_sbuff_parse_error_t *err, _type *out, fr_sbuff } \ if (((errno == EINVAL) && (num == 0)) || ((errno == ERANGE) && (num == ULLONG_MAX))) goto overflow; \ if (no_trailing && (((a_end = in->p + (end - buff)) + 1) < in->end)) { \ - if (isdigit(*a_end) || (((_base > 10) || ((_base == 0) && (len > 2) && (buff[0] == '0') && (buff[1] == 'x'))) && \ - ((tolower(*a_end) >= 'a') && (tolower(*a_end) <= 'f')))) { \ + if (isdigit((uint8_t) *a_end) || (((_base > 10) || ((_base == 0) && (len > 2) && (buff[0] == '0') && (buff[1] == 'x'))) && \ + ((tolower((uint8_t) *a_end) >= 'a') && (tolower((uint8_t) *a_end) <= 'f')))) { \ if (err) *err = FR_SBUFF_PARSE_ERROR_TRAILING; \ *out = (_type)(_max); \ FR_SBUFF_ERROR_RETURN(&our_in); \ @@ -1719,7 +1719,7 @@ size_t fr_sbuff_adv_past_strcase(fr_sbuff_t *sbuff, char const *needle, size_t n end = p + needle_len; for (p = sbuff->p, n_p = needle; p < end; p++, n_p++) { - if (tolower(*p) != tolower(*n_p)) return 0; + if (tolower((uint8_t) *p) != tolower((uint8_t) *n_p)) return 0; } return fr_sbuff_advance(sbuff, needle_len); @@ -2023,7 +2023,7 @@ char *fr_sbuff_adv_to_strcase(fr_sbuff_t *sbuff, size_t len, char const *needle, if (fr_sbuff_extend_lowat(NULL, &our_sbuff, needle_len) < needle_len) break; for (p = our_sbuff.p, n_p = needle, end = our_sbuff.p + needle_len; - (p < end) && (tolower(*p) == tolower(*n_p)); + (p < end) && (tolower((uint8_t) *p) == tolower((uint8_t) *n_p)); p++, n_p++); if (p == end) { (void)fr_sbuff_set(sbuff, our_sbuff.p); diff --git a/src/lib/util/sbuff.h b/src/lib/util/sbuff.h index 881c577122c..ef318675a95 100644 --- a/src/lib/util/sbuff.h +++ b/src/lib/util/sbuff.h @@ -1758,27 +1758,27 @@ static inline bool _fr_marker_is_char(fr_sbuff_marker_t *marker, char *p, char c fr_sbuff_marker_t * : _fr_marker_is_ ## _name((fr_sbuff_marker_t *)(_sbuff_or_marker), fr_sbuff_current(_sbuff_or_marker)) \ ) -SBUFF_IS_FUNC(digit, isdigit(*p)) +SBUFF_IS_FUNC(digit, isdigit((uint8_t) *p)) #define fr_sbuff_is_digit(_sbuff_or_marker) \ SBUFF_IS_GENERIC(_sbuff_or_marker, digit) -SBUFF_IS_FUNC(upper, isupper(*p)) +SBUFF_IS_FUNC(upper, isupper((uint8_t) *p)) #define fr_sbuff_is_upper(_sbuff_or_marker) \ SBUFF_IS_GENERIC(_sbuff_or_marker, upper) -SBUFF_IS_FUNC(lower, islower(*p)) +SBUFF_IS_FUNC(lower, islower((uint8_t) *p)) #define fr_sbuff_is_lower(_sbuff_or_marker) \ SBUFF_IS_GENERIC(_sbuff_or_marker, lower) -SBUFF_IS_FUNC(alpha, isalpha(*p)) +SBUFF_IS_FUNC(alpha, isalpha((uint8_t) *p)) #define fr_sbuff_is_alpha(_sbuff_or_marker) \ SBUFF_IS_GENERIC(_sbuff_or_marker, alpha) -SBUFF_IS_FUNC(space, isspace(*p)) +SBUFF_IS_FUNC(space, isspace((uint8_t) *p)) #define fr_sbuff_is_space(_sbuff_or_marker) \ SBUFF_IS_GENERIC(_sbuff_or_marker, space) -SBUFF_IS_FUNC(hex, isxdigit(*p)) +SBUFF_IS_FUNC(hex, isxdigit((uint8_t) *p)) #define fr_sbuff_is_hex(_sbuff_or_marker) \ SBUFF_IS_GENERIC(_sbuff_or_marker, hex) diff --git a/src/lib/util/snprintf.c b/src/lib/util/snprintf.c index 935636998a5..05d4e09d394 100644 --- a/src/lib/util/snprintf.c +++ b/src/lib/util/snprintf.c @@ -316,7 +316,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); @@ -485,7 +485,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/util/time.c b/src/lib/util/time.c index c27843939eb..6d632e0ed0f 100644 --- a/src/lib/util/time.c +++ b/src/lib/util/time.c @@ -825,7 +825,7 @@ static int get_part(char **str, int *date, int min, int max, char term, char con { char *p = *str; - if (!isdigit((int) *p) || !isdigit((int) p[1])) return -1; + if (!isdigit((uint8_t) *p) || !isdigit((uint8_t) p[1])) return -1; *date = (p[0] - '0') * 10 + (p[1] - '0'); if (*date < min) { @@ -1083,7 +1083,7 @@ int fr_unix_time_from_str(fr_unix_time_t *date, char const *date_str, fr_time_re */ tm->tm_mon = 12; for (i = 0; i < 3; i++) { - if (isalpha((int) *f[i])) { + if (isalpha((uint8_t) *f[i])) { int j; /* diff --git a/src/lib/util/token.c b/src/lib/util/token.c index 4a3190df83f..bdda29a94cc 100644 --- a/src/lib/util/token.c +++ b/src/lib/util/token.c @@ -324,7 +324,7 @@ static fr_token_t getthing(char const **ptr, char *buf, int buflen, bool tok, * comma. */ if (!quote) { - if (isspace((int) *p)) break; + if (isspace((uint8_t) *p)) break; if (tok) { @@ -537,7 +537,7 @@ ssize_t fr_skip_string(char const *start, char const *end) /* * \r or \n, etc. */ - if (!isdigit((int) p[1])) { + if (!isdigit((uint8_t) p[1])) { p += 2; continue; } @@ -553,7 +553,7 @@ ssize_t fr_skip_string(char const *start, char const *end) if (end && ((p + 4) >= end)) goto fail; - if (!isdigit((int) p[2]) || !isdigit((int) p[3])) { + if (!isdigit((uint8_t) p[2]) || !isdigit((uint8_t) p[3])) { fr_strerror_const("Invalid octal escape"); return -(p - start); } diff --git a/src/listen/control/radmin.c b/src/listen/control/radmin.c index de2230ec1e7..f4f94e383d2 100644 --- a/src/listen/control/radmin.c +++ b/src/listen/control/radmin.c @@ -537,7 +537,7 @@ static ssize_t cmd_copy(char const *cmd) for (p += len; p > cmd_buffer; p--) { - if (!isspace((int) p[-1])) break; + if (!isspace((uint8_t) p[-1])) break; p[-1] = '\0'; } @@ -1224,7 +1224,7 @@ int main(int argc, char **argv) * modifies it's behavior. These commands MUST */ if (!stack_depth && (strncmp(line, "local", 5) == 0)) { - if (!isspace((int) line[5])) { + if (!isspace((uint8_t) line[5])) { fprintf(stderr, "'local' commands MUST be specified all on one line"); goto next; } diff --git a/src/listen/cron/proto_cron_crontab.c b/src/listen/cron/proto_cron_crontab.c index 215a558b30b..0c3903953aa 100644 --- a/src/listen/cron/proto_cron_crontab.c +++ b/src/listen/cron/proto_cron_crontab.c @@ -226,7 +226,7 @@ static int parse_field(CONF_ITEM *ci, char const **start, char const *name, /* * EOS or space is end of field. */ - if (!(!*end || isspace((int) *end))) { + if (!(!*end || isspace((uint8_t) *end))) { cf_log_err(ci, "Unexpected text for %s at %s", name, end); return -1; } diff --git a/src/listen/detail/proto_detail_work.c b/src/listen/detail/proto_detail_work.c index f85d1609d94..a4819203a3f 100644 --- a/src/listen/detail/proto_detail_work.c +++ b/src/listen/detail/proto_detail_work.c @@ -345,7 +345,7 @@ redo: /* * Skip attribute name */ - while ((p < end) && !isspace(*p)) p++; + while ((p < end) && !isspace((uint8_t) *p)) p++; /* * Not enough room for " = ", skip this sanity diff --git a/src/modules/rlm_csv/rlm_csv.c b/src/modules/rlm_csv/rlm_csv.c index a7a9aab468d..260c3f26fcf 100644 --- a/src/modules/rlm_csv/rlm_csv.c +++ b/src/modules/rlm_csv/rlm_csv.c @@ -670,7 +670,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) break; } - if (isspace((int) *q)) { + if (isspace((uint8_t) *q)) { cf_log_err(conf, "Field %d name cannot have spaces.", i + 1); return -1; diff --git a/src/modules/rlm_escape/rlm_escape.c b/src/modules/rlm_escape/rlm_escape.c index e1919531f6b..078df5f19e4 100644 --- a/src/modules/rlm_escape/rlm_escape.c +++ b/src/modules/rlm_escape/rlm_escape.c @@ -159,8 +159,8 @@ static xlat_action_t unescape_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, /* Is a = char */ if (((end - p) < 2) || - !(c1 = memchr(hextab, tolower(*(p + 1)), 16)) || - !(c2 = memchr(hextab, tolower(*(p + 2)), 16))) goto next; + !(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); (void) fr_sbuff_in_char(&sbuff, c3); diff --git a/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c b/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c index 49218a48058..ca1f2d930a9 100644 --- a/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c +++ b/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c @@ -306,7 +306,7 @@ static int read_string(rlm_isc_dhcp_tokenizer_t *state) if (*p == '"') { p++; - if (isspace((int) *p)) { + if (isspace((uint8_t) *p)) { if (skip_spaces(state, p) < 0) return -1; break; } @@ -368,7 +368,7 @@ redo: * or semi-colon. We skip those characters * before looking for the next token. */ - while (isspace((int) *state->ptr) || (*state->ptr == ';') || (*state->ptr == ',')) state->ptr++; + while (isspace((uint8_t) *state->ptr) || (*state->ptr == ';') || (*state->ptr == ',')) state->ptr++; if (!*state->ptr) goto redo; @@ -446,7 +446,7 @@ redo: /* * Whitespace, we're done. */ - if (isspace((int) *p)) { + if (isspace((uint8_t) *p)) { if (skip_spaces(state, p) < 0) return -1; break; } @@ -548,13 +548,13 @@ static int match_subword(rlm_isc_dhcp_tokenizer_t *state, char const *cmd, rlm_i * Remember the next command. */ next = q = cmd; - while (*next && !isspace((int) *next) && (*next != ',')) next++; + while (*next && !isspace((uint8_t) *next) && (*next != ',')) next++; if (!*next) semicolon = YES_SEMICOLON; /* * Matching an in-line word. */ - if (islower((int) *q)) { + if (islower((uint8_t) *q)) { ret = read_token(state, T_BARE_WORD, semicolon, false); if (ret <= 0) return -1; @@ -583,7 +583,7 @@ static int match_subword(rlm_isc_dhcp_tokenizer_t *state, char const *cmd, rlm_i * Matched all of this word in 'q', but there are * more words after this one.. Recurse. */ - if (isspace((int) *q)) { + if (isspace((uint8_t) *q)) { return match_subword(state, next, info); } @@ -621,9 +621,9 @@ static int match_subword(rlm_isc_dhcp_tokenizer_t *state, char const *cmd, rlm_i * multiple fields. */ p = type_name; - while (*q && !isspace((int) *q) && (*q != ',')) { + while (*q && !isspace((uint8_t) *q) && (*q != ',')) { if ((p - type_name) >= (int) sizeof(type_name)) return -1; /* internal error */ - *(p++) = tolower((int) *(q++)); + *(p++) = tolower((uint8_t) *(q++)); } *p = '\0'; @@ -1200,7 +1200,7 @@ static int match_keyword(rlm_isc_dhcp_info_t *parent, rlm_isc_dhcp_tokenizer_t * /* * The token exactly matches the command. */ - if (!c || isspace((int) c)) { + if (!c || isspace((uint8_t) c)) { q = &(tokens[half].name[state->token_len]); break; } @@ -1293,7 +1293,7 @@ static int match_keyword(rlm_isc_dhcp_info_t *parent, rlm_isc_dhcp_tokenizer_t * * There's more to this command, * go parse that, too. */ - if (isspace((int) *q)) { + if (isspace((uint8_t) *q)) { if (state->saw_semicolon) goto unexpected; ret = match_subword(state, q, info); diff --git a/src/modules/rlm_logintime/timestr.c b/src/modules/rlm_logintime/timestr.c index 7fd4125835f..f6303a733b4 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/smbdes.c b/src/modules/rlm_mschap/smbdes.c index bacb2336dca..70f03133ef8 100644 --- a/src/modules/rlm_mschap/smbdes.c +++ b/src/modules/rlm_mschap/smbdes.c @@ -324,7 +324,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 36421346c67..5e725d19378 100644 --- a/src/modules/rlm_rest/rest.c +++ b/src/modules/rlm_rest/rest.c @@ -1837,7 +1837,7 @@ int rest_request_config(module_ctx_t const *mctx, rlm_rest_section_t const *sect if (!content_type_set && (strncasecmp(header->vp_strvalue, "content-type:", sizeof("content-type:") - 1) == 0)) { char const *content_type = header->vp_strvalue + (sizeof("content-type:") - 1); - while (isspace((int)*content_type)) content_type++; + while (isspace((uint8_t)*content_type)) content_type++; RDEBUG3("Request body content-type provided as \"%s\"", content_type); diff --git a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c index 03b8f41b794..33d6d053f54 100644 --- a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c +++ b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c @@ -125,12 +125,12 @@ static int find_next_reset(rlm_sqlcounter_t *inst, fr_time_t now) fr_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("num=%d, last=%c",num,last); @@ -189,12 +189,12 @@ static int find_prev_reset(rlm_sqlcounter_t *inst, fr_time_t now) fr_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("num=%d, last=%c", num, last); diff --git a/src/modules/rlm_yubikey/rlm_yubikey.c b/src/modules/rlm_yubikey/rlm_yubikey.c index 4040f5d4bec..d25d5210400 100644 --- a/src/modules/rlm_yubikey/rlm_yubikey.c +++ b/src/modules/rlm_yubikey/rlm_yubikey.c @@ -115,8 +115,8 @@ static ssize_t modhex2hex(char const *modhex, char *hex, size_t len) if (modhex[i + 1] == '\0') return -1; - if (!(c1 = memchr(modhextab, tolower((int) modhex[i]), 16)) || - !(c2 = memchr(modhextab, tolower((int) modhex[i + 1]), 16))) + if (!(c1 = memchr(modhextab, tolower((uint8_t) modhex[i]), 16)) || + !(c2 = memchr(modhextab, tolower((uint8_t) modhex[i + 1]), 16))) return -1; hex[i] = hextab[c1 - modhextab];