]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
ctype macros should take explicitly unsigned input
authorAlan T. DeKok <aland@freeradius.org>
Mon, 16 Jan 2023 13:05:54 +0000 (08:05 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 16 Jan 2023 13:14:01 +0000 (08:14 -0500)
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)

43 files changed:
scripts/build/dlopen.c
src/bin/collectd.c
src/bin/dhcpclient.c
src/bin/radclient.c
src/bin/radsnmp.c
src/bin/unit_test_attribute.c
src/lib/ldap/filter.c
src/lib/server/cf_file.c
src/lib/server/command.c
src/lib/server/cond_tokenize.c
src/lib/server/dl_module.c
src/lib/server/exec.c
src/lib/server/exec_legacy.c
src/lib/server/tmpl_tokenize.c
src/lib/tls/session.c
src/lib/unlang/compile.c
src/lib/unlang/xlat_builtin.c
src/lib/unlang/xlat_expr.c
src/lib/util/dict_tokenize.c
src/lib/util/dict_util.c
src/lib/util/getaddrinfo.c
src/lib/util/hash.c
src/lib/util/inet.c
src/lib/util/misc.c
src/lib/util/misc.h
src/lib/util/pair_tokenize.c
src/lib/util/print.c
src/lib/util/sbuff.c
src/lib/util/sbuff.h
src/lib/util/snprintf.c
src/lib/util/time.c
src/lib/util/token.c
src/listen/control/radmin.c
src/listen/cron/proto_cron_crontab.c
src/listen/detail/proto_detail_work.c
src/modules/rlm_csv/rlm_csv.c
src/modules/rlm_escape/rlm_escape.c
src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c
src/modules/rlm_logintime/timestr.c
src/modules/rlm_mschap/smbdes.c
src/modules/rlm_rest/rest.c
src/modules/rlm_sqlcounter/rlm_sqlcounter.c
src/modules/rlm_yubikey/rlm_yubikey.c

index 9775aaa6acacc07217f26fe34669642368a36e7f..622fa44fe3994cd01dc3afd646cbb924aeb057d5 100644 (file)
@@ -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 {
index 3295f50e7d6b71d040c1904cec5e468655dac1f6..495a6d839f29f3d2702041526465fbf5dd666603 100644 (file)
@@ -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);\
index e9e060e86fde7de9957f4136c7aec9c7e60af8c7..30b969ad0cfd73debcbba032117502a8ebe3fdb2 100644 (file)
@@ -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]);
index ef0f65eb5a5b6db308bfb2effc5bfb43b13b0960..8927ef0b127c60e1c2c64f6fd5d7bf5707d1a417 100644 (file)
@@ -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]);
index 2854b7dae9cc13d36a86ee7c2f6c607b9554130b..55fd6192ec7986c82489f2b67e64f14183b23c92 100644 (file)
@@ -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);
index b922632e8ae6300c8e7327c958a83fdc442ae4a1..adc8e21a868452c42aabf4806b3a5e3e49684c72 100644 (file)
@@ -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++;
        }
index c22f401ad06cda019cb43ff8731482669799fdfd..afc33032ceaac97491c246dd7fd94405741b6df9 100644 (file)
@@ -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++;
index 5e124c04840377e5efa7fcb67e29a174aa616f3a..c7dc8d2e6af01a4069f7fa43ee054641618d2e7e 100644 (file)
@@ -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;
index fcb6790fbdcd040cf2de6ca62436c3c049286e98..0dbd54ae80aa5d151ffd955e267c95ecd1339959 100644 (file)
@@ -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++;
                                }
index 3e2b351581a26268fbae1d0e00c91aca7dc2d418..c487b158cba283c17ec61bf596244f1ef16eeea7 100644 (file)
@@ -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;
index 61511de95b0b894af96e75e1bcd43ed86f0a5b88..f839df373d3066d778cda78615b77b79913e1e2f 100644 (file)
@@ -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.
index 0a9d52e9d2a8fbd0886356bb19cddf5831ac09d3..128928a7e360ab09b920f0180ddcaebc4e01c4a7 100644 (file)
@@ -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 = '_';
                }
 
index af90dace57e58b533ce6d06cb53b9ec8397a39b3..075c9eac65d348375f2a649eb7af48cdad9d17ce 100644 (file)
@@ -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);
                                }
                        }
                }
index d6a89190470efdff2133705e6da8f0d7ee50366d..c1234bddafcc6756b94620b475f4c17ff9fb01d5 100644 (file)
@@ -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;
                        }
 
index e4c2f1fcf7dfdd3878ddf18faff6fdd4b998062f..c2b5096531ea4464ebd7835e014f598108a250a1 100644 (file)
@@ -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;
index 2c42df18d0772972526ef330555afb555c8c3271..703a44df818774a5e745aaa780fa4af0997b6062 100644 (file)
@@ -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());
index 6392185953c6128687e9b90f4c5e1d233dacd585..a79a87639daa5322b4e5cb4da0ea5b305e9c60e9 100644 (file)
@@ -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);
        }
 
        /*
index c19b47e61d35d113c13e957e83cb941651e1b4c5..c078cf177faf31d733322f581bb95de4554c1c9e 100644 (file)
@@ -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,
index e8d499568e18dbf45f2dbfe68ab91059f555f333..b4d8193d3dadeb0851bb7c25bd2fa733bd84db64 100644 (file)
@@ -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);
index c622d024e6cead0f3f43f594a9ba04dc1e341fa5..89030f869994859c0a39e72404643444a269ad47 100644 (file)
@@ -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
index 182e8b858a45d1a3700e2452fa9651046e526d3a..56294125bc1d3b9b148cef87e9469f87973f19bd 100644 (file)
@@ -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;
index 79e0a2c4bd5f7b7ca38c3e0874510a1d92b37a87..6ceeaa4f74ea379d554b8766ffd61b568af676d3 100644 (file)
@@ -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;
index 7277dfa3697e3e88a4be62e028c9fa80f8cb0e42..3086f5832a8cb121c7f81fb6ed7f6278a6647e90 100644 (file)
@@ -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;
                        /*
index c00ffb382dbc4bc5bf88e5746b1282d6400d4c9d..647e465423e1527157beaf15ac5b4576d50bdaa9 100644 (file)
@@ -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;
 }
index 31ea5a6161cb9198c0e6f7fcf37f335f1696a2bb..033faa4c37f7c21f6a4960f415f4415b2cfe1143 100644 (file)
@@ -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;
index d2c9fe0e3485f4d5bf3ef79fd87c8cfff0f1a87d..e91f43eaa0e777d97466b3553a9ed3f59408d539 100644 (file)
@@ -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;
 
        /*
index 78404f45bfdfb07abdb930c1a980da276a9a3eed..8dfb41abd63fbd09d475d3daf1833f600cbf95ad 100644 (file)
@@ -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;
                }
 
index 6b5e53ee83f1a695496ea0f94d514332ec75d0ff..b2c23a20f6557b27944331e59f5312ecaa78e7c5 100644 (file)
@@ -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);
index 881c577122cfd816cd533cfa5cc4140da32e0ac7..ef318675a95fcfd843116d0bd31762688f99ee55 100644 (file)
@@ -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)
 
index 935636998a5f660b041ffeaf5899f729814bbecd..05d4e09d39460e996eba4fdc0a3219073a51fc8a 100644 (file)
@@ -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';
index c27843939ebf42876c75d179ffee651cb0a36af5..6d632e0ed0f84a2e23d1ca753c757fb82a3be7be 100644 (file)
@@ -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;
 
                        /*
index 4a3190df83fb0d2fa3f7139c2b901992eb03918f..bdda29a94cce0d67ced63ef005090209663cc5aa 100644 (file)
@@ -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);
                }
index de2230ec1e79c87dc7513d33c4ab98c087b5f119..f4f94e383d28d605703411287e9d00d9d20bea1d 100644 (file)
@@ -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;
                        }
index 215a558b30befe711465128c676e4b414663a8c1..0c3903953aaa0627ed5e7865bd6de03b4dd54896 100644 (file)
@@ -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;
                }
index f85d1609d94bab6a4fdee614a2f7bcb0ca72c93d..a4819203a3f63f338330d037a6e6d5945f3e2643 100644 (file)
@@ -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
index a7a9aab468d84d689c51d21274dbcb25a3c0953f..260c3f26fcfc6f67fdbbd5f50b6e23a58de5e26e 100644 (file)
@@ -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;
index e1919531f6bed9c31433fc07d47921e8b041f685..078df5f19e480a5d63c9702690ff152aab78504b 100644 (file)
@@ -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);
index 49218a48058a025dc537ef68018d941897593c98..ca1f2d930a91ae7291085f329aa271e5e9394811 100644 (file)
@@ -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);
index 7fd4125835f5b91935d2f79cb467b7bed3aaba2c..f6303a733b491b787aec8fce4711f43201cea8cd 100644 (file)
@@ -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) {
index bacb2336dca440bbf79472e8e358ffa145753727..70f03133ef8a81fda0d2040c5942ba861a872734 100644 (file)
@@ -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);
index 36421346c678454d3e06f319bdeaa36a4f35a5fe..5e725d19378b07c9e8d1360e3b0816f3a1617504 100644 (file)
@@ -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);
                                
index 03b8f41b79434baca4c4e60277c82fe1b8630b8b..33d6d053f54787e5208b0491b375fedfb36b97e8 100644 (file)
@@ -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);
index 4040f5d4bec21e57a48a5a1c93d0769cb2193eff..d25d5210400d7719e504fb583419687fceb2b24f 100644 (file)
@@ -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];