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 
This commit is contained in:
Johannes Schlatow 2021-12-08 16:28:19 +01:00 committed by Norman Feske
parent 162ddb1fdb
commit b1bbd72e84

@ -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;
}