HBASE-19431 The tag array written by IndividualBytesFieldCell#write is out of bounds
This commit is contained in:
parent
6d69fd9c78
commit
e29685ed6d
|
@ -155,7 +155,7 @@ public class IndividualBytesFieldCell implements ExtendedCell {
|
|||
out.write((byte)(0xff & getTagsLength()));
|
||||
|
||||
// Tags byte array
|
||||
out.write(tags);
|
||||
out.write(tags, tagsOffset, tagsLength);
|
||||
}
|
||||
|
||||
return getSerializedSize(withTags);
|
||||
|
|
|
@ -239,4 +239,24 @@ public class TestIndividualBytesFieldCell {
|
|||
Bytes.toBytes("value"), 0, 5,
|
||||
Bytes.toBytes("tags"), 0, 100);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWriteTag() throws IOException {
|
||||
byte[] tags = Bytes.toBytes("---tags---");
|
||||
int tagOffset = 3;
|
||||
int length = 4;
|
||||
IndividualBytesFieldCell cell
|
||||
= new IndividualBytesFieldCell(Bytes.toBytes("row"), 0, 3,
|
||||
Bytes.toBytes("family"), 0, 6,
|
||||
Bytes.toBytes("qualifier"), 0, 9,
|
||||
0L, KeyValue.Type.Put, 0,
|
||||
Bytes.toBytes("value"), 0, 5,
|
||||
tags, tagOffset, length);
|
||||
|
||||
try (ByteArrayOutputStream output = new ByteArrayOutputStream(300)) {
|
||||
cell.write(output, true);
|
||||
byte[] buf = output.toByteArray();
|
||||
assertEquals(cell.getSerializedSize(true), buf.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue