Skip to content

Commit

Permalink
better guard against corrupt sctp chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
massemanet committed Apr 9, 2019
1 parent 92f5a0d commit 15ea41b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/pkt_sctp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ decode_chunks(Chunks, Acc) ->
end.

%%% if 'chunks' is less than 4 bytes, we can't read a length.
%%% if 'length' is less than 5, the chunk is corrupt.
%%% we return 'sizeof chunks' plus one, indicating that a read will fail.
chunk_len(<<_:16, L:16, _/binary>>) ->
chunk_len(<<_:16, L:16, _/binary>>) when 4 < L ->
L-4+chunk_pad_len(L);
chunk_len(Chunks) ->
byte_size(Chunks)+1.
Expand Down

0 comments on commit 15ea41b

Please sign in to comment.