2004-10-13 Paul Jakma <paul@dishone.st>

	* (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.
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 90219cf..23b8d84 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -180,7 +180,7 @@
 }
 
 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 @@
 }
 
 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;
 }