From 8a1e1a8c952f681d0d20ba9ae16f117940e16965 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Tue, 26 Sep 2017 14:41:57 +0200 Subject: Fix error in DAT package sent for empty packages Also made sure that if this happens again monitor.cc should at least not hang but assert and break instead --- src/monitor.cc | 5 +++++ src/proxy.cc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/monitor.cc b/src/monitor.cc index cffe3d5..b2157f7 100644 --- a/src/monitor.cc +++ b/src/monitor.cc @@ -164,6 +164,11 @@ private: size_t offset = 0; while (offset + 5 < package_fill_) { uint16_t size = read_u16(package_ + offset + 3); + if (size == 0) { + assert(false); + offset += 5; + break; + } if (offset + size > package_fill_) break; size_t o = 5; if (size >= 3 && memcmp(package_ + offset, "PKG", 3) == 0) { diff --git a/src/proxy.cc b/src/proxy.cc index b8df00c..e68645f 100644 --- a/src/proxy.cc +++ b/src/proxy.cc @@ -1942,7 +1942,7 @@ void ProxyImpl::send_attached_data(uint32_t id, void const* ptr, size_t size, if (size == 0) { assert(last); assert(ptr == nullptr); - write_u16(data + 3, 10); + write_u16(data + 3, 22); data[9] = 0; send_attached(data, 22, nullptr, 0); } else { -- cgit v1.2.3-70-g09d2