Skip to content

Commit

Permalink
Strip trailing bytes from network packets
Browse files Browse the repository at this point in the history
  • Loading branch information
talex5 committed Jun 3, 2015
1 parent 22c4332 commit 725cbb7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ipv4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ module Make(Ethif : V1_LWT.ETHIF) (Clock : V1.CLOCK) (Time : V1_LWT.TIME) = stru
let payload_len = Wire_structs.Ipv4_wire.get_ipv4_len buf - ihl in
let hdr, data = Cstruct.split buf ihl in
if Cstruct.len data >= payload_len then begin
(* Strip trailing bytes. See: https://github.com/mirage/mirage-net-xen/issues/24 *)
let data = Cstruct.sub data 0 payload_len in
let proto = Wire_structs.Ipv4_wire.get_ipv4_proto buf in
match Wire_structs.Ipv4_wire.int_to_protocol proto with
| Some `ICMP -> icmp_input t src hdr data
Expand Down

0 comments on commit 725cbb7

Please sign in to comment.