libsofiasip: fix buffer overrun (SFSIP-136)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12914 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2009-04-03 23:04:42 +00:00
parent db4b11711d
commit eaf0c7c8b5

View File

@ -212,8 +212,9 @@ sofia_su_uniqueid_destructor(void)
#endif #endif
#endif #endif
#define SIZEOF_NODE 6
static static
void init_node(uint8_t node[6]) void init_node(uint8_t node[SIZEOF_NODE])
{ {
#if HAVE_GETIFADDRS && HAVE_SOCKADDR_LL #if HAVE_GETIFADDRS && HAVE_SOCKADDR_LL
struct ifaddrs *ifa, *results; struct ifaddrs *ifa, *results;
@ -234,7 +235,7 @@ void init_node(uint8_t node[6])
continue; continue;
} }
memcpy(node, sll->sll_addr, sizeof node); memcpy(node, sll->sll_addr, SIZEOF_NODE);
break; break;
#endif #endif
@ -247,16 +248,16 @@ void init_node(uint8_t node[6])
} }
#endif #endif
su_randmem(node, 6); su_randmem(node, SIZEOF_NODE);
node[0] |= 1; /* "multicast" address */ node[0] |= 1; /* "multicast" address */
} }
static unsigned char node[6]; static unsigned char node[SIZEOF_NODE];
size_t su_node_identifier(void *address, size_t addrlen) size_t su_node_identifier(void *address, size_t addrlen)
{ {
if (addrlen > sizeof node) if (addrlen > SIZEOF_NODE)
addrlen = sizeof node; addrlen = SIZEOF_NODE;
su_guid_generate(NULL); su_guid_generate(NULL);
memcpy(address, node, addrlen); memcpy(address, node, addrlen);