forked from osmocom/wireshark
replace one sprintf with g_snprintf and move one array off the stack and into emem allocated memory
svn path=/trunk/; revision=15653
This commit is contained in:
parent
5521c10492
commit
98ed9bee0a
1 changed files with 5 additions and 3 deletions
|
@ -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) ==
|
||||
|
|
Loading…
Reference in a new issue