[Java] Flexbuffers - Negative signed object length (#6651)

* retry with correct email

* update JavaTest.java
This commit is contained in:
Samir Ahmed
2021-05-20 11:57:10 -07:00
committed by GitHub
parent fbcb3c4236
commit 54c11932fa
2 changed files with 23 additions and 1 deletions

View File

@@ -862,6 +862,27 @@ class JavaTest {
TestEq((byte)-1, result[3]);
}
public static void testSingleElementLongBlob() {
// verifies blobs of up to 2^16 in length
for (int i = 2; i <= 1<<16; i = i<<1) {
byte[] input = new byte[i-1];
for (int index = 0; index < input.length; index++) {
input[index] = (byte)(index % 64);
}
FlexBuffersBuilder builder = new FlexBuffersBuilder();
builder.putBlob(input);
ByteBuffer b = builder.finish();
FlexBuffers.Reference r = FlexBuffers.getRoot(b);
byte[] result = r.asBlob().getBytes();
for (int index = 0; index < input.length; index++) {
TestEq((byte)(index % 64), result[index]);
}
}
}
public static void testSingleElementUByte() {
FlexBuffersBuilder builder = new FlexBuffersBuilder();
builder.putUInt(0xFF);
@@ -1084,6 +1105,7 @@ class JavaTest {
testSingleElementSmallString();
testSingleElementBigString();
testSingleElementBlob();
testSingleElementLongBlob();
testSingleElementVector();
testSingleFixedTypeVector();
testSingleElementUShort();