Skip to content

Commit

Permalink
Add not-failing test that tries to reproduce #473: has the data but c…
Browse files Browse the repository at this point in the history
…all sequence not same as OSS-Fuzzer (#474)
  • Loading branch information
cowtowncoder authored Jan 27, 2024
1 parent c57f7be commit fb855c0
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.fasterxml.jackson.dataformat.ion.failing;

import org.hamcrest.Matchers;
import org.junit.Test;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.exc.StreamReadException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.ion.*;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

//[dataformats-binary#473]: ArrayIndexOutOfBoundsException
//https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66131
public class IonFuzz_473_66131_AIOOBE_Test
{
private final ObjectMapper ION_MAPPER = new IonObjectMapper();

@Test
public void testFuzz66077_ArrayIndexOOBE() throws Exception {
final byte[] doc = { (byte) 0xe0, 0x01, 0x00, (byte) 0xea, (byte) 0xdc, (byte) 0x9a };
try (JsonParser p = ION_MAPPER.createParser(doc)) {
assertEquals(JsonToken.START_OBJECT, p.nextToken());
p.nextTextValue();
fail("Should not pass (invalid content)");
} catch (StreamReadException e) {
assertThat(e.getMessage(), Matchers.containsString("Corrupt content to decode"));
}
}
}

0 comments on commit fb855c0

Please sign in to comment.