From fd79ac918b8feaacebe9719adaac97dffb69137a Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 13 Oct 2004 05:06:08 +0000 Subject: 2004-10-13 Paul Jakma * (global) more const'ification and fixups of types to clean up code. * bgp_mplsvpn.{c,h}: (str2tag) fix abuse. Still not perfect, should use something like the VTY_GET_INTEGER macro, but without the vty_out bits.. * bgp_routemap.c: (set_aggregator_as) use VTY_GET_INTEGER_RANGE (no_set_aggregator_as) ditto. * bgpd.c: (peer_uptime) fix unlikely bug, where no buffer is returned, add comments about troublesome return value. --- bgpd/bgp_mplsvpn.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'bgpd/bgp_mplsvpn.c') diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 90219cfe..23b8d84b 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -180,7 +180,7 @@ bgp_nlri_parse_vpnv4 (struct peer *peer, struct attr *attr, } int -str2prefix_rd (char *str, struct prefix_rd *prd) +str2prefix_rd (const char *str, struct prefix_rd *prd) { int ret; char *p; @@ -236,15 +236,22 @@ str2prefix_rd (char *str, struct prefix_rd *prd) } int -str2tag (char *str, u_char *tag) +str2tag (const char *str, u_char *tag) { - u_int32_t l; + unsigned long l; + char *endptr; + u_int32_t t; - l = atol (str); + l = strtoul (str, &endptr, 10); + + if (*endptr == '\0' || l == ULONG_MAX || l > UINT32_MAX) + return 0; - tag[0] = (u_char)(l >> 12); - tag[1] = (u_char)(l >> 4); - tag[2] = (u_char)(l << 4); + t = (u_int32_t) l; + + tag[0] = (u_char)(t >> 12); + tag[1] = (u_char)(t >> 4); + tag[2] = (u_char)(t << 4); return 1; } -- cgit v1.2.1