summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@opera.com>2017-09-26 14:41:57 +0200
committerJoel Klinghed <the_jk@opera.com>2017-09-26 14:43:13 +0200
commit8a1e1a8c952f681d0d20ba9ae16f117940e16965 (patch)
tree67375eddf1f540d761796a0ff80be5033d1534a0
parent4bc57e1aff741f2bad1884574c8fe29b51ee5f16 (diff)
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
-rw-r--r--src/monitor.cc5
-rw-r--r--src/proxy.cc2
2 files changed, 6 insertions, 1 deletions
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 {