From 42d498658d85e36a7e5910955e7425b1fa2afa69 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 13 Oct 2004 05:22:18 +0000 Subject: 2004-10-13 Paul Jakma * (global) more const'ification. * sockunion.c: (sockunion_su2str) buffer should be sized SU_ADDRSTRLEN. (sockunion_log) do not return stack variables, strdup buf before return. * vty.h: Fix up the VTY_GET_INTEGER macros. Testing caller supplied values against ULONG_MAX is daft, when caller probably has passed a type that can not hold ULONG_MAX. use a temporary long instead. Add VTY_GET_LONG, make VTY_GET_INTEGER_RANGE use it, make VTY_GET_INTEGER a define for VTY_GET_INTEGER_RANGE. --- lib/sockunion.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/sockunion.c') diff --git a/lib/sockunion.c b/lib/sockunion.c index eb29ced2..78e02f26 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -175,7 +175,7 @@ sockunion2str (union sockunion *su, char *buf, size_t len) } union sockunion * -sockunion_str2su (char *str) +sockunion_str2su (const char *str) { int ret; union sockunion *su; @@ -211,7 +211,7 @@ sockunion_str2su (char *str) char * sockunion_su2str (union sockunion *su) { - char str[INET6_ADDRSTRLEN]; + char str[SU_ADDRSTRLEN]; switch (su->sa.sa_family) { @@ -314,7 +314,7 @@ sockunion_log (union sockunion *su) snprintf (buf, SU_ADDRSTRLEN, "af_unknown %d ", su->sa.sa_family); break; } - return buf; + return (strdup (buf)); } /* sockunion_connect returns @@ -676,7 +676,7 @@ sockunion_print (union sockunion *su) #ifdef HAVE_IPV6 case AF_INET6: { - char buf [64]; + char buf [SU_ADDRSTRLEN]; printf ("%s\n", inet_ntop (AF_INET6, &(su->sin6.sin6_addr), buf, sizeof (buf))); -- cgit v1.2.3