-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Arthur Chan <[email protected]>
- Loading branch information
1 parent
6b38ebf
commit 10fdbde
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz420_65062_65083IOOBETest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.fasterxml.jackson.dataformat.ion.fuzz; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.Assert.fail; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
|
||
import com.fasterxml.jackson.core.exc.StreamReadException; | ||
import com.fasterxml.jackson.dataformat.ion.*; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
// [dataformats-binary#417] | ||
public class Fuzz420_65062_65083IOOBETest | ||
{ | ||
private void testIOOBE(byte[] array) throws Exception { | ||
IonFactory f = IonFactory | ||
.builderForTextualWriters() | ||
.enable(IonParser.Feature.USE_NATIVE_TYPE_ID) | ||
.build(); | ||
IonObjectMapper mapper = IonObjectMapper.builder(f).build(); | ||
try { | ||
mapper.readTree(mapper.getFactory().createParser(new ByteArrayInputStream(array))); | ||
fail("Should not pass (invalid content)"); | ||
} catch (StreamReadException e) { | ||
assertThat(e.getMessage(), Matchers.containsString("Invalid type ID")); | ||
} | ||
} | ||
|
||
@Test | ||
public void testFuzz6506265083IOOBE() throws Exception { | ||
byte[] byteArray = Files.readAllBytes(Paths.get("tc1")); | ||
testIOOBE(byteArray); | ||
} | ||
} |