|
| 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 | +} |
0 commit comments