Skip to content

Commit 8d1b125

Browse files
committed
Add test for #473: currently fails to reproduce the issue but has content that should allow repro
1 parent 8b1fcd5 commit 8d1b125

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.fasterxml.jackson.dataformat.ion.failing;
2+
3+
import org.hamcrest.Matchers;
4+
import org.junit.Test;
5+
6+
import com.fasterxml.jackson.core.JsonParser;
7+
import com.fasterxml.jackson.core.JsonToken;
8+
import com.fasterxml.jackson.core.exc.StreamReadException;
9+
import com.fasterxml.jackson.databind.ObjectMapper;
10+
import com.fasterxml.jackson.dataformat.ion.*;
11+
import com.fasterxml.jackson.dataformat.ion.fuzz.IonFuzzTestUtil;
12+
13+
import static org.hamcrest.MatcherAssert.assertThat;
14+
import static org.junit.Assert.assertEquals;
15+
import static org.junit.Assert.assertNull;
16+
import static org.junit.Assert.fail;
17+
18+
//[dataformats-binary#]: ArrayIndexOutOfBoundsException
19+
//https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66131
20+
public class IonFuzz_473_66131_AIOOBE_Test
21+
{
22+
private final ObjectMapper ION_MAPPER = new IonObjectMapper();
23+
24+
@Test
25+
public void testFuzz66077_NegativeArraySize() throws Exception {
26+
final byte[] doc = IonFuzzTestUtil.readResource("/data/fuzz-66131.ion");
27+
try (JsonParser p = ION_MAPPER.createParser(doc)) {
28+
assertEquals(JsonToken.VALUE_STRING, p.nextToken());
29+
assertNull(p.nextToken());
30+
fail("Should not pass (invalid content)");
31+
} catch (StreamReadException e) {
32+
// May or may not be the exception message to get, change as appropriate
33+
assertThat(e.getMessage(), Matchers.containsString("Corrupt content to decode"));
34+
}
35+
}
36+
}
50 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)