]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix other casts for array indexes fr_dict_attr_allowed_chars
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 31 May 2018 18:46:30 +0000 (00:46 +0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 31 May 2018 18:46:30 +0000 (00:46 +0600)
src/lib/util/dict.c
src/lib/util/pair.c
src/main/cond_tokenize.c
src/main/tmpl.c

index c8b70b0e0236b3755f2a40057e5e635d175fd81f..8eb9f5521ec0d7540ee440be34a7cc0c75ac4446 100644 (file)
@@ -2480,7 +2480,7 @@ ssize_t fr_dict_unknown_afrom_oid_substr(TALLOC_CTX *ctx, fr_dict_attr_t **out,
         *      Advance p until we get something that's not part of
         *      the dictionary attribute name.
         */
-       for (p = name; fr_dict_attr_allowed_chars[(int)*p] || (*p == '.') || (*p == '-'); p++);
+       for (p = name; fr_dict_attr_allowed_chars[(uint8_t)*p] || (*p == '.') || (*p == '-'); p++);
 
        len = p - name;
        if (len > FR_DICT_ATTR_MAX_NAME_LEN) {
@@ -2903,7 +2903,7 @@ ssize_t fr_dict_by_protocol_substr(fr_dict_t **out, char const *name)
         *      Advance p until we get something that's not part of
         *      the dictionary attribute name.
         */
-       for (p = name; fr_dict_attr_allowed_chars[(int)*p] && (*p != '.'); p++);
+       for (p = name; fr_dict_attr_allowed_chars[(uint8_t)*p] && (*p != '.'); p++);
 
        len = p - name;
        if (len > FR_DICT_ATTR_MAX_NAME_LEN) {
@@ -3235,7 +3235,7 @@ ssize_t fr_dict_attr_by_name_substr(fr_dict_attr_t const **out, fr_dict_t const
         *      Advance p until we get something that's not part of
         *      the dictionary attribute name.
         */
-       for (p = name; fr_dict_attr_allowed_chars[(int)*p]; p++);
+       for (p = name; fr_dict_attr_allowed_chars[(uint8_t)*p]; p++);
 
        len = p - name;
        if (len > FR_DICT_ATTR_MAX_NAME_LEN) {
index 457e76e25cabc6ad3c8fd55aec1f39cd7ded31a6..94390711b915d27a66743c6d311ddfc0e4a69ee5 100644 (file)
@@ -291,7 +291,7 @@ ssize_t fr_pair_afrom_substr(TALLOC_CTX *ctx, VALUE_PAIR **out,
                quote = '\0';
                q = p;
 
-               while (fr_dict_attr_allowed_chars[(int)*q] != '\0') q++;
+               while (fr_dict_attr_allowed_chars[(uint8_t)*q] != '\0') q++;
                break;
        }
 
@@ -2660,10 +2660,8 @@ FR_TOKEN fr_pair_raw_from_str(char const **ptr, VALUE_PAIR_RAW *raw)
                 *      This is arguably easier than trying to figure
                 *      out which operators come after the attribute
                 *      name.  Yes, our "lexer" is bad.
-                *
-                *  sizeof() is for coverity.
                 */
-               if ((*t >= sizeof(fr_dict_attr_allowed_chars)) || !fr_dict_attr_allowed_chars[*t]) break;
+               if (!fr_dict_attr_allowed_chars[(uint8_t)*t]) break;
 
                /*
                 *      Attribute:=value is NOT
index d0f42455b3a45049e1e39f5e15a768104d55486b..2f56798086ef44af2cfe49864cea59b372f0918a 100644 (file)
@@ -1183,7 +1183,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, CONF_ITEM *ci, char const *start,
                                         *      e.g. LDAP-Group and SQL-Group.
                                         */
                                        for (i = 0; i < c->data.map->lhs->len; i++) {
-                                               if (!fr_dict_attr_allowed_chars[(unsigned char) c->data.map->lhs->name[i]]) {
+                                               if (!fr_dict_attr_allowed_chars[(uint8_t) c->data.map->lhs->name[i]]) {
                                                        may_be_attr = false;
                                                        break;
                                                }
index a334de27cee648c68e85e8b1776e7684c6fac9f5..292b4293214da4c8bd2d984db5c801a00c864a2b 100644 (file)
@@ -717,7 +717,7 @@ ssize_t tmpl_afrom_attr_substr(TALLOC_CTX *ctx, vp_tmpl_t **out, char const *nam
                 *      Copy the name to a field for later resolution
                 */
                vpt->type = TMPL_TYPE_ATTR_UNDEFINED;
-               for (q = p; fr_dict_attr_allowed_chars[(int) *q]; q++);
+               for (q = p; fr_dict_attr_allowed_chars[(uint8_t) *q]; q++);
                if (q == p) {
                        fr_strerror_printf("Invalid attribute name");
                        slen = -(p - name);
@@ -2042,7 +2042,7 @@ size_t tmpl_snprint(char *out, size_t outlen, vp_tmpl_t const *vpt)
                for (p = vpt->name; *p != '\0'; p++) {
                        if (*p == ' ') break;
                        if (*p == '\'') break;
-                       if (!fr_dict_attr_allowed_chars[(int) *p]) break;
+                       if (!fr_dict_attr_allowed_chars[(uint8_t) *p]) break;
                }
                c = *p ? '"' : '\0';