org.ice4j.attribute: fix bytes conversion bugs (#67)
http://findbugs.sourceforge.net/bugDescriptions.html#BIT_IOR_OF_SIGNED_BYTE http://findbugs.sourceforge.net/bugDescriptions.html#BIT_ADD_OF_SIGNED_BYTE Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>
This commit is contained in:
parent
ce4126701e
commit
08f6ee8c64
@ -54,10 +54,10 @@ public class AttributeDecoder
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Discover attribute type
|
//Discover attribute type
|
||||||
char attributeType = (char)((bytes[offset] << 8) | bytes[offset + 1]);
|
char attributeType = (char)
|
||||||
int len1 = bytes[offset + 2] & 0xff;
|
(((bytes[offset] & 0xFF) << 8) | (bytes[offset + 1] & 0xFF));
|
||||||
int len2 = bytes[offset + 3] & 0xff;
|
char attributeLength = (char)
|
||||||
char attributeLength = (char)((len1 << 8) | len2);
|
(((bytes[offset + 2] & 0xFF) << 8) | (bytes[offset + 3] & 0xFF));
|
||||||
|
|
||||||
if(attributeLength > bytes.length - offset )
|
if(attributeLength > bytes.length - offset )
|
||||||
throw new StunException( StunException.ILLEGAL_ARGUMENT,
|
throw new StunException( StunException.ILLEGAL_ARGUMENT,
|
||||||
|
|||||||
@ -282,7 +282,8 @@ public class MessageIntegrityAttribute
|
|||||||
binValue[3] = (byte)(getDataLength() & 0x00FF);
|
binValue[3] = (byte)(getDataLength() & 0x00FF);
|
||||||
|
|
||||||
byte[] key = null;
|
byte[] key = null;
|
||||||
char msgType = (char)((content[0] << 8) + content[1]);
|
char msgType =
|
||||||
|
(char) (((content[0] & 0xFF) << 8) | (content[1] & 0xFF));
|
||||||
|
|
||||||
if(Message.isRequestType(msgType))
|
if(Message.isRequestType(msgType))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -229,8 +229,8 @@ public class UnknownAttributesAttribute extends Attribute
|
|||||||
char originalOffset = offset;
|
char originalOffset = offset;
|
||||||
for(int i = offset; i < originalOffset + length; i += 2)
|
for(int i = offset; i < originalOffset + length; i += 2)
|
||||||
{
|
{
|
||||||
char attributeID = (char)( (attributeValue[offset++] << 8) |
|
char attributeID = (char) (((attributeValue[offset++] & 0xFF) << 8)
|
||||||
(attributeValue[offset++]) );
|
| (attributeValue[offset++] & 0xFF));
|
||||||
addAttributeID(attributeID);
|
addAttributeID(attributeID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user