From: Arran Cudbard-Bell Date: Thu, 31 May 2018 18:46:30 +0000 (+0600) Subject: Fix other casts for array indexes fr_dict_attr_allowed_chars X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e46e46a55d956a4b51cc5adeb08f4257eb5162ec;p=thirdparty%2Ffreeradius-server.git Fix other casts for array indexes fr_dict_attr_allowed_chars --- diff --git a/src/lib/util/dict.c b/src/lib/util/dict.c index c8b70b0e023..8eb9f5521ec 100644 --- a/src/lib/util/dict.c +++ b/src/lib/util/dict.c @@ -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) { diff --git a/src/lib/util/pair.c b/src/lib/util/pair.c index 457e76e25ca..94390711b91 100644 --- a/src/lib/util/pair.c +++ b/src/lib/util/pair.c @@ -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 diff --git a/src/main/cond_tokenize.c b/src/main/cond_tokenize.c index d0f42455b3a..2f56798086e 100644 --- a/src/main/cond_tokenize.c +++ b/src/main/cond_tokenize.c @@ -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; } diff --git a/src/main/tmpl.c b/src/main/tmpl.c index a334de27cee..292b4293214 100644 --- a/src/main/tmpl.c +++ b/src/main/tmpl.c @@ -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';