Commit e4b671de authored by Dafydd Harries's avatar Dafydd Harries

don't use StunAttribute.length as packed value length when packing messages

darcs-hash:20070130100801-c9803-bd4067a42ceac4b97f25d5c8dbaa30a062709185.gz
parent 650f53e9
...@@ -98,6 +98,8 @@ stun_attribute_pack (StunAttribute *attr, gchar **packed) ...@@ -98,6 +98,8 @@ stun_attribute_pack (StunAttribute *attr, gchar **packed)
switch (attr->type) switch (attr->type)
{ {
case STUN_ATTRIBUTE_MAPPED_ADDRESS: case STUN_ATTRIBUTE_MAPPED_ADDRESS:
{
if (packed != NULL)
{ {
StunAttribute *ret = g_malloc0 (sizeof (StunAttribute)); StunAttribute *ret = g_malloc0 (sizeof (StunAttribute));
...@@ -107,6 +109,8 @@ stun_attribute_pack (StunAttribute *attr, gchar **packed) ...@@ -107,6 +109,8 @@ stun_attribute_pack (StunAttribute *attr, gchar **packed)
ret->address.port = htons (attr->address.port); ret->address.port = htons (attr->address.port);
ret->address.ip = htonl (attr->address.ip); ret->address.ip = htonl (attr->address.ip);
*packed = (gchar *) ret; *packed = (gchar *) ret;
}
return 12; return 12;
} }
default: default:
...@@ -230,7 +234,7 @@ stun_message_pack (StunMessage *msg, gchar **packed) ...@@ -230,7 +234,7 @@ stun_message_pack (StunMessage *msg, gchar **packed)
StunAttribute **attr; StunAttribute **attr;
for (attr = msg->attributes; *attr; attr++) for (attr = msg->attributes; *attr; attr++)
length += 4 + (*attr)->length; length += stun_attribute_pack (*attr, NULL);
} }
packed_type = htons (msg->type); packed_type = htons (msg->type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment