Skip to content

Commit

Permalink
Discard malformed packets.
Browse files Browse the repository at this point in the history
  • Loading branch information
wnagele committed Sep 2, 2014
1 parent 036700c commit 3d1d30a
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ private byte[] buildTcpAndUdpPacket(Packet packet, byte[] packetData, int ipProt
* @return payload as byte[]
*/
protected byte[] readPayload(byte[] packetData, int payloadDataStart, int payloadLength) {
if (payloadLength < 0) {
LOG.warn("Malformed packet - negative payload length. Returning empty payload.");
return new byte[0];
}
if (payloadDataStart > packetData.length) {
LOG.warn("Payload start (" + payloadDataStart + ") is larger than packet data (" + packetData.length + "). Returning empty payload.");
return new byte[0];
Expand Down

0 comments on commit 3d1d30a

Please sign in to comment.