Skip to content
Snippets Groups Projects
Commit 641cd435 authored by Shudong Zhou's avatar Shudong Zhou
Browse files

BSC-3970 Catch malformed ARP packets

parent c87ae730
No related branches found
No related tags found
No related merge requests found
......@@ -225,12 +225,27 @@ public class ARP extends BasePacket {
}
@Override
public IPacket deserialize(byte[] data, int offset, int length) {
public IPacket deserialize(byte[] data, int offset, int length)
throws PacketParsingException {
ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
this.hardwareType = bb.getShort();
this.protocolType = bb.getShort();
this.hardwareAddressLength = bb.get();
this.protocolAddressLength = bb.get();
if (this.hardwareAddressLength != 6) {
if (log.isTraceEnabled()) {
log.trace("Incorrect ARP hardware address length: {}",
hardwareAddressLength);
}
throw new PacketParsingException();
}
if (this.protocolAddressLength != 4) {
if (log.isTraceEnabled()) {
log.trace("Incorrect ARP protocol address length: {}",
protocolAddressLength);
}
throw new PacketParsingException();
}
this.opCode = bb.getShort();
this.senderHardwareAddress = new byte[0xff & this.hardwareAddressLength];
bb.get(this.senderHardwareAddress, 0, this.senderHardwareAddress.length);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment