From 1b5b2c37a0eb7c99d17af5c27ee0df948f90a1a1 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Sat, 13 Aug 2016 17:12:34 -0700 Subject: [PATCH] Fix readVarLong. --- .../org/spacehq/packetlib/io/buffer/ByteBufferNetInput.java | 6 +++--- .../org/spacehq/packetlib/io/stream/StreamNetInput.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/spacehq/packetlib/io/buffer/ByteBufferNetInput.java b/src/main/java/org/spacehq/packetlib/io/buffer/ByteBufferNetInput.java index af2e051b..9c71c128 100644 --- a/src/main/java/org/spacehq/packetlib/io/buffer/ByteBufferNetInput.java +++ b/src/main/java/org/spacehq/packetlib/io/buffer/ByteBufferNetInput.java @@ -77,17 +77,17 @@ public class ByteBufferNetInput implements NetInput { @Override public long readVarLong() throws IOException { - int value = 0; + long value = 0; int size = 0; int b; while(((b = this.readByte()) & 0x80) == 0x80) { - value |= (b & 0x7F) << (size++ * 7); + value |= (long) (b & 0x7F) << (size++ * 7); if(size > 10) { throw new IOException("VarLong too long (length must be <= 10)"); } } - return value | ((b & 0x7F) << (size * 7)); + return value | ((long) (b & 0x7F) << (size * 7)); } @Override diff --git a/src/main/java/org/spacehq/packetlib/io/stream/StreamNetInput.java b/src/main/java/org/spacehq/packetlib/io/stream/StreamNetInput.java index 69d1d1b4..3433f4fe 100644 --- a/src/main/java/org/spacehq/packetlib/io/stream/StreamNetInput.java +++ b/src/main/java/org/spacehq/packetlib/io/stream/StreamNetInput.java @@ -93,17 +93,17 @@ public class StreamNetInput implements NetInput { @Override public long readVarLong() throws IOException { - int value = 0; + long value = 0; int size = 0; int b; while(((b = this.readByte()) & 0x80) == 0x80) { - value |= (b & 0x7F) << (size++ * 7); + value |= (long) (b & 0x7F) << (size++ * 7); if(size > 10) { throw new IOException("VarLong too long (length must be <= 10)"); } } - return value | ((b & 0x7F) << (size * 7)); + return value | ((long) (b & 0x7F) << (size * 7)); } @Override