You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ch...@apache.org on 2017/12/11 03:05:40 UTC

hbase git commit: HBASE-19484 The value array written by ExtendedCell#write is out of bounds

Repository: hbase
Updated Branches:
  refs/heads/branch-2 e444f549d -> 6010daf8b


HBASE-19484 The value array written by ExtendedCell#write is out of bounds


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/6010daf8
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6010daf8
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6010daf8

Branch: refs/heads/branch-2
Commit: 6010daf8b052c72d6c2e2f11481e5751bdd37545
Parents: e444f54
Author: Chia-Ping Tsai <ch...@gmail.com>
Authored: Mon Dec 11 09:10:14 2017 +0800
Committer: Chia-Ping Tsai <ch...@gmail.com>
Committed: Mon Dec 11 11:01:25 2017 +0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/ExtendedCell.java   |  2 +-
 .../hbase/TestIndividualBytesFieldCell.java     | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/6010daf8/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java
index 73fbf67..d491326 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCell.java
@@ -54,7 +54,7 @@ public interface ExtendedCell extends RawCell, HeapSize, Cloneable {
     PrivateCellUtil.writeFlatKey(this, out);
 
     // Value
-    out.write(getValueArray());
+    out.write(getValueArray(), getValueOffset(), getValueLength());
 
     // Tags length and tags byte array
     if (withTags && getTagsLength() > 0) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/6010daf8/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java
index f98c68e..9abf908 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestIndividualBytesFieldCell.java
@@ -252,4 +252,24 @@ public class TestIndividualBytesFieldCell {
       assertEquals(cell.getSerializedSize(true), buf.length);
     }
   }
+
+  @Test
+  public void testWriteValue() throws IOException {
+    byte[] value = Bytes.toBytes("---value---");
+    int valueOffset = 3;
+    int valueLength = 5;
+    IndividualBytesFieldCell cell
+        = new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3,
+        Bytes.toBytes("family"), 0, 6,
+        Bytes.toBytes("qualifier"), 0, 9,
+        0L, KeyValue.Type.Put, 0,
+        value, valueOffset, valueLength,
+        Bytes.toBytes("value"), 0, 5);
+
+    try (ByteArrayOutputStream output = new ByteArrayOutputStream(300)) {
+      cell.write(output, true);
+      byte[] buf = output.toByteArray();
+      assertEquals(cell.getSerializedSize(true), buf.length);
+    }
+  }
 }