summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_mplsvpn.c8
-rw-r--r--bgpd/bgp_routemap.c20
-rw-r--r--lib/vty.h3
-rw-r--r--ospfd/ospf_vty.c5
4 files changed, 26 insertions, 10 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 72ad089e..c1f1fbb3 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -233,9 +233,13 @@ str2tag (const char *str, u_char *tag)
char *endptr;
u_int32_t t;
- l = strtoul (str, &endptr, 10);
+ if (*str == '-')
+ return 0;
- if (*endptr == '\0' || l == ULONG_MAX || l > UINT32_MAX)
+ errno = 0;
+ l = strtoul (str, &endptr, 10);
+
+ if (*endptr != '\0' || errno || l > UINT32_MAX)
return 0;
t = (u_int32_t) l;
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 05bc304b..abb85fd2 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -525,8 +525,13 @@ route_match_metric_compile (const char *arg)
char *endptr = NULL;
unsigned long tmpval;
+ /* Metric value shoud be integer. */
+ if (! all_digit (arg))
+ return NULL;
+
+ errno = 0;
tmpval = strtoul (arg, &endptr, 10);
- if (*endptr != '\0' || tmpval == ULONG_MAX || tmpval > UINT32_MAX)
+ if (*endptr != '\0' || errno || tmpval > UINT32_MAX)
return NULL;
med = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
@@ -1002,8 +1007,9 @@ route_set_local_pref_compile (const char *arg)
if (! all_digit (arg))
return NULL;
+ errno = 0;
tmp = strtoul (arg, &endptr, 10);
- if (*endptr != '\0' || tmp == ULONG_MAX || tmp > UINT32_MAX)
+ if (*endptr != '\0' || errno || tmp > UINT32_MAX)
return NULL;
local_pref = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
@@ -1070,9 +1076,9 @@ route_set_weight_compile (const char *arg)
if (! all_digit (arg))
return NULL;
-
+ errno = 0;
tmp = strtoul (arg, &endptr, 10);
- if (*endptr != '\0' || tmp == ULONG_MAX || tmp > UINT32_MAX)
+ if (*endptr != '\0' || errno || tmp > UINT32_MAX)
return NULL;
weight = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
@@ -1161,8 +1167,9 @@ route_set_metric_compile (const char *arg)
if (all_digit (arg))
{
/* set metric value check*/
+ errno = 0;
larg = strtoul (arg, &endptr, 10);
- if (*endptr != '\0' || larg == ULONG_MAX || larg > UINT32_MAX)
+ if (*endptr != '\0' || errno || larg > UINT32_MAX)
return NULL;
metric = larg;
}
@@ -1174,8 +1181,9 @@ route_set_metric_compile (const char *arg)
|| (! all_digit (arg+1)))
return NULL;
+ errno = 0;
larg = strtoul (arg+1, &endptr, 10);
- if (*endptr != '\0' || larg == ULONG_MAX || larg > UINT32_MAX)
+ if (*endptr != '\0' || errno || larg > UINT32_MAX)
return NULL;
metric = larg;
}
diff --git a/lib/vty.h b/lib/vty.h
index 7df04b5f..639d7417 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -152,8 +152,9 @@ struct vty
#define VTY_GET_LONG(NAME,V,STR) \
do { \
char *endptr = NULL; \
+ errno = 0; \
(V) = strtoul ((STR), &endptr, 10); \
- if (*endptr != '\0' || (V) == ULONG_MAX) \
+ if (*(STR) == '-' || *endptr != '\0' || errno) \
{ \
vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
return CMD_WARNING; \
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index c928e819..97c8e8d6 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -80,8 +80,11 @@ ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
/* match "<0-4294967295>". */
else
{
+ if (*str == '-')
+ return -1;
+ errno = 0;
ret = strtoul (str, &endptr, 10);
- if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE))
+ if (*endptr != '\0' || errno || ret > UINT32_MAX)
return -1;
area_id->s_addr = htonl (ret);