From b1bbd72e8437e8d8bcc9961690fbc2eb2ba9ff15 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Wed, 8 Dec 2021 16:28:19 +0100 Subject: [PATCH] net: fix tail size calculation in Ethernet_frame The const-variant of the data() method contained an erroneous calculation of the tail size. This led to the size guard throwing exceptions when trying to parse TCP packets that only contained the TCP header. Fixes genodelabs/genode#4340 --- repos/os/include/net/ethernet.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/repos/os/include/net/ethernet.h b/repos/os/include/net/ethernet.h index a03099e7d8..f78afe7bb5 100644 --- a/repos/os/include/net/ethernet.h +++ b/repos/os/include/net/ethernet.h @@ -78,9 +78,8 @@ class Net::Ethernet_frame T const &obj = *(T *)(_data); /* Ethernet may have a tail whose size must be considered */ - Genode::size_t const unconsumed = size_guard.unconsumed(); - size_guard.consume_tail(unconsumed + sizeof(T) - - obj.size(unconsumed)); + Genode::size_t const max_obj_sz = size_guard.unconsumed() + sizeof(T); + size_guard.consume_tail(max_obj_sz - obj.size(max_obj_sz)); return obj; }