You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2017/09/07 16:17:41 UTC
[05/14] activemq git commit: [AMQ-6771] fix off by one on input
stream read long check, with test
[AMQ-6771] fix off by one on input stream read long check, with test
(cherry picked from commit 3cd5529f505907912476a054758612a2eb22a1e0)
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/a023c7a3
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/a023c7a3
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/a023c7a3
Branch: refs/heads/activemq-5.15.x
Commit: a023c7a3e43dcec28d823d20a92fa982d483f773
Parents: ba5e814
Author: gtully <ga...@gmail.com>
Authored: Tue Jul 18 12:28:12 2017 +0100
Committer: Timothy Bish <ta...@gmail.com>
Committed: Thu Sep 7 12:10:44 2017 -0400
----------------------------------------------------------------------
.../apache/activemq/util/DataByteArrayInputStream.java | 2 +-
.../activemq/util/DataByteArrayInputStreamTest.java | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/a023c7a3/activemq-client/src/main/java/org/apache/activemq/util/DataByteArrayInputStream.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/util/DataByteArrayInputStream.java b/activemq-client/src/main/java/org/apache/activemq/util/DataByteArrayInputStream.java
index 3b42c9f..0f21696 100644
--- a/activemq-client/src/main/java/org/apache/activemq/util/DataByteArrayInputStream.java
+++ b/activemq-client/src/main/java/org/apache/activemq/util/DataByteArrayInputStream.java
@@ -226,7 +226,7 @@ public final class DataByteArrayInputStream extends InputStream implements DataI
}
public long readLong() throws IOException {
- if (pos + 8 >= buf.length ) {
+ if (pos + 8 > buf.length ) {
throw new EOFException();
}
long rc = ((long)buf[pos++] << 56) + ((long)(buf[pos++] & 255) << 48) + ((long)(buf[pos++] & 255) << 40) + ((long)(buf[pos++] & 255) << 32);
http://git-wip-us.apache.org/repos/asf/activemq/blob/a023c7a3/activemq-client/src/test/java/org/apache/activemq/util/DataByteArrayInputStreamTest.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/test/java/org/apache/activemq/util/DataByteArrayInputStreamTest.java b/activemq-client/src/test/java/org/apache/activemq/util/DataByteArrayInputStreamTest.java
index 3ba4a49..632bfa3 100644
--- a/activemq-client/src/test/java/org/apache/activemq/util/DataByteArrayInputStreamTest.java
+++ b/activemq-client/src/test/java/org/apache/activemq/util/DataByteArrayInputStreamTest.java
@@ -76,4 +76,15 @@ public class DataByteArrayInputStreamTest {
String readBack = in.readUTF();
assertEquals(value, readBack);
}
+
+ @Test
+ public void testReadLong() throws Exception {
+ DataByteArrayOutputStream out = new DataByteArrayOutputStream(8);
+ out.writeLong(Long.MAX_VALUE);
+ out.close();
+
+ DataByteArrayInputStream in = new DataByteArrayInputStream(out.getData());
+ long readBack = in.readLong();
+ assertEquals(Long.MAX_VALUE, readBack);
+ }
}