Skip to content

Commit

Permalink
fixes the negative length
Browse files Browse the repository at this point in the history
  • Loading branch information
fireflies-xlt authored Nov 28, 2020
1 parent 0ebd10e commit 8125dde
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ static void encodeByteString(ByteBuf byteBuf, String s) {

static String decodeByteString(ByteBuf byteBuf, int offset) {
int length = byteBuf.getByte(offset);
length &= UNSIGNED_BYTE_MAX_VALUE;
offset += Byte.BYTES;

return byteBuf.toString(offset, length, StandardCharsets.UTF_8);
}

static int decodeByteStringLength(ByteBuf byteBuf, int offset) {
int length = byteBuf.getByte(offset);
length &= UNSIGNED_BYTE_MAX_VALUE;
return Byte.BYTES + length;
}

Expand Down

0 comments on commit 8125dde

Please sign in to comment.