diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2005-09-01 09:40:55 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2005-09-01 09:40:55 +0000 |
commit | 98ed9bee0a6cd2d70fb8563937fed0a745c6c39d (patch) | |
tree | 25fd499b694ad1851b4ab959d6c6cab4c26d5f6d /epan | |
parent | 5521c10492202568467d39127392854e101306bb (diff) |
replace one sprintf with g_snprintf and move one array off the stack and into emem allocated memory
svn path=/trunk/; revision=15653
Diffstat (limited to 'epan')
-rw-r--r-- | epan/inet_ntop.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/epan/inet_ntop.c b/epan/inet_ntop.c index 1d32204ccc..b2ce3e6be1 100644 --- a/epan/inet_ntop.c +++ b/epan/inet_ntop.c @@ -57,6 +57,7 @@ static char rcsid[] = "$Id$"; #include <string.h> #include "inet_v6defs.h" +#include "emem.h" #include <glib.h> @@ -156,11 +157,12 @@ inet_ntop6(src, dst, size) * Keep this in mind if you think this function should have been coded * to use pointer overlays. All the world's not a VAX. */ - char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; + char *tmp, *tp; struct { int base, len; } best, cur; u_int words[NS_IN6ADDRSZ / NS_INT16SZ]; int i; + tmp=ep_alloc(128); /* large enough for "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"] */ /* * Preprocess: * Copy the input (bytewise) array into a wordwise array. @@ -210,12 +212,12 @@ inet_ntop6(src, dst, size) /* Is this address an encapsulated IPv4? */ if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { - if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) + if (!inet_ntop4(src+12, tp, 128 - (tp - tmp))) return (NULL); tp += strlen(tp); break; } - tp += sprintf(tp, "%x", words[i]); + tp += g_snprintf(tp, 128-(tp-tmp), "%x", words[i]); } /* Was it a trailing run of 0x00's? */ if (best.base != -1 && (best.base + best.len) == |