Commit e4b671de authored by Dafydd Harries's avatar Dafydd Harries
Browse files

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

darcs-hash:20070130100801-c9803-bd4067a42ceac4b97f25d5c8dbaa30a062709185.gz
parent 650f53e9
...@@ -99,14 +99,18 @@ stun_attribute_pack (StunAttribute *attr, gchar **packed) ...@@ -99,14 +99,18 @@ stun_attribute_pack (StunAttribute *attr, gchar **packed)
{ {
case STUN_ATTRIBUTE_MAPPED_ADDRESS: case STUN_ATTRIBUTE_MAPPED_ADDRESS:
{ {
StunAttribute *ret = g_malloc0 (sizeof (StunAttribute)); if (packed != NULL)
{
ret->type = htons (attr->type); StunAttribute *ret = g_malloc0 (sizeof (StunAttribute));
ret->length = htons (8);
ret->address.af = attr->address.af; ret->type = htons (attr->type);
ret->address.port = htons (attr->address.port); ret->length = htons (8);
ret->address.ip = htonl (attr->address.ip); ret->address.af = attr->address.af;
*packed = (gchar *) ret; ret->address.port = htons (attr->address.port);
ret->address.ip = htonl (attr->address.ip);
*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