Commit 3759a85a authored by Jonathan Michalon's avatar Jonathan Michalon

libovcc: allow zero-length payload messages (ie. empty Variant array)

parent 254e8562
......@@ -148,14 +148,18 @@ namespace OVCC.Network
throws Error
{
var len = stream.read_uint16 (cancel);
if (len < 1 || len > 0x4000 /* arbitrary limit not to fulfill memory */) {
if (len < 0 || len > 0x4000 /* arbitrary limit not to fulfill memory */) {
throw new MessageError.MALFORMED_MESSAGE ("Invalid message length %u",
len);
}
var buf = new uint8[len];
stream.read (buf, cancel);
return buf;
if (len > 0) {
var buf = new uint8[len];
stream.read (buf, cancel);
return buf;
} else {
return null;
}
}
protected bool write_buffer (DataOutputStream stream,
......@@ -164,7 +168,11 @@ namespace OVCC.Network
throws Error
{
stream.put_uint16 ((uint16)buf.length, cancel);
return stream.write (buf, cancel) == buf.length;
if (buf.length > 0) {
return stream.write (buf, cancel) == buf.length;
} else {
return true;
}
}
}
}
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