Corrects detection of STUN packets if the current UDP datagram has no PDU.

This commit is contained in:
chenzo 2012-06-19 13:27:50 +00:00
parent b0c3647242
commit 5434a8ab41

View File

@ -174,10 +174,15 @@ public class StunDatagramPacketFilter
* other protocols when STUN is multiplexed with other protocols * other protocols when STUN is multiplexed with other protocols
* on the same port. * on the same port.
*/ */
boolean isStunPacket = false;
byte[] data = p.getData(); byte[] data = p.getData();
int offset = p.getOffset(); int offset = p.getOffset();
byte b0 = data[offset];
return ((b0 & 0xC0) == 0); if(data.length - offset > 0)
{
byte b0 = data[offset];
isStunPacket = ((b0 & 0xC0) == 0);
}
return isStunPacket;
} }
} }