Skip to content

Commit

Permalink
apps.ipv6.reassemble: fix check for valid packet length
Browse files Browse the repository at this point in the history
Take padding to minimum Ethernet frame size into account.
  • Loading branch information
alexandergall committed Jan 29, 2019
1 parent d054ec0 commit 69473eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/apps/ipv6/reassemble.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ local fragment_header_ptr_t = ffi.typeof('$*', fragment_header_t)
-- Precondition: packet already has IPv6 ethertype.
local function ipv6_packet_has_valid_length(h, len)
if len < ether_ipv6_header_len then return false end
return ntohs(h.ipv6.payload_length) == len - ether_ipv6_header_len
-- The minimum Ethernet frame size is 60 bytes (without FCS). Those
-- frames may contain padding bytes.
local payload_length = ntohs(h.ipv6.payload_length)
return payload_length <= 60 or payload_length == len - ether_ipv6_header_len
end

local function swap(array, i, j)
Expand Down

0 comments on commit 69473eb

Please sign in to comment.