summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2019-08-06 16:54:52 +0200
committerDavid Lamparter <equinox@diac24.net>2019-08-06 16:54:52 +0200
commitfefa5e0ff5af98d8258987e21422243926ee2b3c (patch)
tree05ad830d4a48048156689b15a5c84df124964cb6 /bgpd
parentMerge pull request #4776 from pogojotz/write-config-fix (diff)
downloadfrr-fefa5e0ff5af98d8258987e21422243926ee2b3c.tar.xz
frr-fefa5e0ff5af98d8258987e21422243926ee2b3c.zip
*: fix ctype (isalpha & co.) casts
The correct cast for these is (unsigned char), because "char" could be signed and thus have some negative value. isalpha & co. expect an int arg that is positive, i.e. 0-255. So we need to cast to (unsigned char) when calling any of these. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_aspath.c6
-rw-r--r--bgpd/bgp_clist.c2
-rw-r--r--bgpd/bgp_community.c8
-rw-r--r--bgpd/bgp_dump.c2
-rw-r--r--bgpd/bgp_ecommunity.c22
-rw-r--r--bgpd/bgp_filter.c2
-rw-r--r--bgpd/bgp_lcommunity.c6
7 files changed, 24 insertions, 24 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index cf0d28887..1385345d6 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -1885,7 +1885,7 @@ static const char *aspath_gettoken(const char *buf, enum as_token *token,
const char *p = buf;
/* Skip seperators (space for sequences, ',' for sets). */
- while (isspace((int)*p) || *p == ',')
+ while (isspace((unsigned char)*p) || *p == ',')
p++;
/* Check the end of the string and type specify characters
@@ -1920,14 +1920,14 @@ static const char *aspath_gettoken(const char *buf, enum as_token *token,
}
/* Check actual AS value. */
- if (isdigit((int)*p)) {
+ if (isdigit((unsigned char)*p)) {
as_t asval;
*token = as_token_asval;
asval = (*p - '0');
p++;
- while (isdigit((int)*p)) {
+ while (isdigit((unsigned char)*p)) {
asval *= 10;
asval += (*p - '0');
p++;
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index ad5553d9a..29e668d17 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -157,7 +157,7 @@ community_list_insert(struct community_list_handler *ch, const char *name,
/* If name is made by all digit character. We treat it as
number. */
for (number = 0, i = 0; i < strlen(name); i++) {
- if (isdigit((int)name[i]))
+ if (isdigit((unsigned char)name[i]))
number = (number * 10) + (name[i] - '0');
else
break;
diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c
index 6fc52ff9e..22d61f702 100644
--- a/bgpd/bgp_community.c
+++ b/bgpd/bgp_community.c
@@ -651,7 +651,7 @@ community_gettoken(const char *buf, enum community_token *token, uint32_t *val)
const char *p = buf;
/* Skip white space. */
- while (isspace((int)*p))
+ while (isspace((unsigned char)*p))
p++;
/* Check the end of the line. */
@@ -659,7 +659,7 @@ community_gettoken(const char *buf, enum community_token *token, uint32_t *val)
return NULL;
/* Well known community string check. */
- if (isalpha((int)*p)) {
+ if (isalpha((unsigned char)*p)) {
if (strncmp(p, "internet", strlen("internet")) == 0) {
*val = COMMUNITY_INTERNET;
*token = community_token_no_export;
@@ -770,13 +770,13 @@ community_gettoken(const char *buf, enum community_token *token, uint32_t *val)
}
/* Community value. */
- if (isdigit((int)*p)) {
+ if (isdigit((unsigned char)*p)) {
int separator = 0;
int digit = 0;
uint32_t community_low = 0;
uint32_t community_high = 0;
- while (isdigit((int)*p) || *p == ':') {
+ while (isdigit((unsigned char)*p) || *p == ':') {
if (*p == ':') {
if (separator) {
*token = community_token_unknown;
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index 7ea6ae586..535f36ab5 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -584,7 +584,7 @@ static unsigned int bgp_dump_parse_time(const char *str)
len = strlen(str);
for (i = 0; i < len; i++) {
- if (isdigit((int)str[i])) {
+ if (isdigit((unsigned char)str[i])) {
time *= 10;
time += str[i] - '0';
} else if (str[i] == 'H' || str[i] == 'h') {
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index 76bd0e815..850b85aa6 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -352,7 +352,7 @@ static const char *ecommunity_gettoken(const char *str,
char buf[INET_ADDRSTRLEN + 1];
/* Skip white space. */
- while (isspace((int)*p)) {
+ while (isspace((unsigned char)*p)) {
p++;
str++;
}
@@ -362,38 +362,38 @@ static const char *ecommunity_gettoken(const char *str,
return NULL;
/* "rt" and "soo" keyword parse. */
- if (!isdigit((int)*p)) {
+ if (!isdigit((unsigned char)*p)) {
/* "rt" match check. */
- if (tolower((int)*p) == 'r') {
+ if (tolower((unsigned char)*p) == 'r') {
p++;
- if (tolower((int)*p) == 't') {
+ if (tolower((unsigned char)*p) == 't') {
p++;
*token = ecommunity_token_rt;
return p;
}
- if (isspace((int)*p) || *p == '\0') {
+ if (isspace((unsigned char)*p) || *p == '\0') {
*token = ecommunity_token_rt;
return p;
}
goto error;
}
/* "soo" match check. */
- else if (tolower((int)*p) == 's') {
+ else if (tolower((unsigned char)*p) == 's') {
p++;
- if (tolower((int)*p) == 'o') {
+ if (tolower((unsigned char)*p) == 'o') {
p++;
- if (tolower((int)*p) == 'o') {
+ if (tolower((unsigned char)*p) == 'o') {
p++;
*token = ecommunity_token_soo;
return p;
}
- if (isspace((int)*p) || *p == '\0') {
+ if (isspace((unsigned char)*p) || *p == '\0') {
*token = ecommunity_token_soo;
return p;
}
goto error;
}
- if (isspace((int)*p) || *p == '\0') {
+ if (isspace((unsigned char)*p) || *p == '\0') {
*token = ecommunity_token_soo;
return p;
}
@@ -415,7 +415,7 @@ static const char *ecommunity_gettoken(const char *str,
* OPQR: Four byte value
*
*/
- while (isdigit((int)*p) || *p == ':' || *p == '.') {
+ while (isdigit((unsigned char)*p) || *p == ':' || *p == '.') {
if (*p == ':') {
if (separator)
goto error;
diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c
index d4f608d40..30a964a22 100644
--- a/bgpd/bgp_filter.c
+++ b/bgpd/bgp_filter.c
@@ -193,7 +193,7 @@ static struct as_list *as_list_insert(const char *name)
/* If name is made by all digit character. We treat it as
number. */
for (number = 0, i = 0; i < strlen(name); i++) {
- if (isdigit((int)name[i]))
+ if (isdigit((unsigned char)name[i]))
number = (number * 10) + (name[i] - '0');
else
break;
diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c
index 098374fa9..2b09a2954 100644
--- a/bgpd/bgp_lcommunity.c
+++ b/bgpd/bgp_lcommunity.c
@@ -359,7 +359,7 @@ static const char *lcommunity_gettoken(const char *str,
const char *p = str;
/* Skip white space. */
- while (isspace((int)*p)) {
+ while (isspace((unsigned char)*p)) {
p++;
str++;
}
@@ -369,14 +369,14 @@ static const char *lcommunity_gettoken(const char *str,
return NULL;
/* Community value. */
- if (isdigit((int)*p)) {
+ if (isdigit((unsigned char)*p)) {
int separator = 0;
int digit = 0;
uint32_t globaladmin = 0;
uint32_t localdata1 = 0;
uint32_t localdata2 = 0;
- while (isdigit((int)*p) || *p == ':') {
+ while (isdigit((unsigned char)*p) || *p == ':') {
if (*p == ':') {
if (separator == 2) {
*token = lcommunity_token_unknown;