Skip to content

Commit

Permalink
Fixed bug when having UnknownTcpOption with zero data, avoid extracti…
Browse files Browse the repository at this point in the history
…ng sub array from the raw data.

If the length is equal to 2 then it means there is no data, an empty data array will be created.
  • Loading branch information
kadarlevi@gmail.com authored and kadarlevi@gmail.com committed Aug 2, 2018
1 parent 3846607 commit 3ba83e4
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ private UnknownTcpOption(
throw new IllegalRawDataException(sb.toString());
}

this.data = ByteArrays.getSubArray(rawData, 2 + offset, this.length - 2);
if (this.length > 2)
this.data = ByteArrays.getSubArray(rawData, 2 + offset, this.length - 2);
else
this.data = new byte[]{};
}

private UnknownTcpOption(Builder builder) {
Expand Down

0 comments on commit 3ba83e4

Please sign in to comment.