From 779f8d1fc48c5d4433346fd2b8c1815310697d53 Mon Sep 17 00:00:00 2001 From: krial057 Date: Tue, 14 May 2019 00:45:53 +0200 Subject: [PATCH] Wrong byte offsets for error codes Hey, it seems you had a +1 index offset error at parsing the error code attribute. Here for reference: https://tools.ietf.org/html/rfc5389#section-15.6 kind regards --- src/main/java/de/javawi/jstun/attribute/ErrorCode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/javawi/jstun/attribute/ErrorCode.java b/src/main/java/de/javawi/jstun/attribute/ErrorCode.java index 04436dd..85972b6 100644 --- a/src/main/java/de/javawi/jstun/attribute/ErrorCode.java +++ b/src/main/java/de/javawi/jstun/attribute/ErrorCode.java @@ -85,10 +85,10 @@ public static ErrorCode parse(byte[] data) throws MessageAttributeParsingExcepti if (data.length < 4) { throw new MessageAttributeParsingException("Data array too short"); } - byte classHeaderByte = data[3]; + byte classHeaderByte = data[2]; int classHeader = Utility.oneByteToInteger(classHeaderByte); if ((classHeader < 1) || (classHeader > 6)) throw new MessageAttributeParsingException("Class parsing error"); - byte numberByte = data[4]; + byte numberByte = data[3]; int number = Utility.oneByteToInteger(numberByte); if ((number < 0) || (number > 99)) throw new MessageAttributeParsingException("Number parsing error"); int responseCode = (classHeader * 100) + number;