From: Mikko Rasa Date: Sat, 10 Dec 2022 17:59:30 +0000 (+0200) Subject: Fix a length calculation bug in Protocol::dispatch X-Git-Url: http://git.tdb.fi/?p=libs%2Fnet.git;a=commitdiff_plain;h=667ae5c9d69dcfbd0a82d8abc8a221e25d4d4ca6 Fix a length calculation bug in Protocol::dispatch The packet header was not being included in the returned length. --- diff --git a/source/net/protocol.cpp b/source/net/protocol.cpp index cee1836..95ba175 100644 --- a/source/net/protocol.cpp +++ b/source/net/protocol.cpp @@ -56,11 +56,11 @@ const Protocol::PacketDefBase &Protocol::get_packet_by_id(unsigned id) const size_t Protocol::dispatch(ReceiverBase &rcv, const char *buf, size_t size) const { PacketHeader header; - buf = header_def.deserialize(header, buf, buf+size); + const char *ptr = header_def.deserialize(header, buf, buf+size); if(header.length>size) throw bad_packet("truncated"); const PacketDefBase &pdef = get_packet_by_id(header.type); - const char *ptr = pdef.dispatch(rcv, buf, buf+header.length); + ptr = pdef.dispatch(rcv, ptr, ptr+header.length); return ptr-buf; }