Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bpf: workaround for missing padding

Probably due to a bug somewhere, the final 2 byte pad of some packets
is stripped. If the real size of the data is equal to the sum of
the capture and header length from the bpf header, set the pad to
0.
  • Loading branch information...
commit 3789543068d27df9e59ac5c50c7f40b1193b45f5 1 parent de06651
@msantos authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/bpf.erl
View
10 src/bpf.erl
@@ -243,7 +243,15 @@ data(Data) when is_binary(Data) ->
Time = {Sec div 1000000, Sec rem 1000000, Usec},
- Pad = pad(Hdrlen + Caplen),
+ % FIXME In some cases, 2 bytes of padding is lost or
+ % FIXME dropped. For example, a packet of 174 bytes
+ % FIXME should be padded to 176 bytes, but only 174
+ % FIXME bytes is left in the buf.
+ Len = Hdrlen + Caplen,
+ Pad = case byte_size(Data) of
+ Len -> 0;
+ _ -> pad(Len)
+ end,
% Include the padding
<<_Hdr:Hdrlen/bytes,
Please sign in to comment.
Something went wrong with that request. Please try again.