activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: [AMQ-6771] fix off by one on input stream read long check, with test
Date Tue, 18 Jul 2017 11:28:57 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 8c218ee05 -> 3cd5529f5


[AMQ-6771] fix off by one on input stream read long check, with test


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/3cd5529f
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/3cd5529f
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/3cd5529f

Branch: refs/heads/master
Commit: 3cd5529f505907912476a054758612a2eb22a1e0
Parents: 8c218ee
Author: gtully <gary.tully@gmail.com>
Authored: Tue Jul 18 12:28:12 2017 +0100
Committer: gtully <gary.tully@gmail.com>
Committed: Tue Jul 18 12:28:12 2017 +0100

----------------------------------------------------------------------
 .../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/3cd5529f/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/3cd5529f/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);
+    }
 }


Mime
View raw message