-
-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
80ae368
commit bf8d729
Showing
7 changed files
with
110 additions
and
20 deletions.
There are no files selected for viewing
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
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
59 changes: 59 additions & 0 deletions
59
ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz434_65268_65274_NPETest.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,59 @@ | ||
package com.fasterxml.jackson.dataformat.ion.fuzz; | ||
|
||
import java.io.*; | ||
|
||
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.assertNull; | ||
import static org.junit.Assert.fail; | ||
|
||
// [dataformats-binary#434] | ||
public class Fuzz434_65268_65274_NPETest | ||
{ | ||
private final ObjectMapper ION_MAPPER = new IonObjectMapper(); | ||
|
||
// Test that used to fail on "getNumberType()" for `JsonToken.VALUE_NULL` | ||
@Test | ||
public void testFuzz65268() throws Exception { | ||
try (InputStream in = getClass().getResourceAsStream("/data/fuzz-65268.ion")) { | ||
try (JsonParser p = ION_MAPPER.createParser(in)) { | ||
assertEquals(JsonToken.VALUE_STRING, p.nextToken()); | ||
p.getText(); | ||
assertNull(p.nextTextValue()); | ||
assertEquals(JsonToken.VALUE_NULL, p.currentToken()); | ||
assertNull(p.getNumberType()); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testFuzz65274Malformed() throws Exception { | ||
try (InputStream in = getClass().getResourceAsStream("/data/fuzz-65274.ion")) { | ||
byte[] invalid = new byte[in.available()]; | ||
new DataInputStream(in).readFully(invalid); | ||
ION_MAPPER.readTree(new ByteArrayInputStream(invalid)); | ||
fail("Should not pass (invalid content)"); | ||
} catch (StreamReadException e) { | ||
assertThat(e.getMessage(), Matchers.containsString("Corrupt content to decode")); | ||
} | ||
} | ||
|
||
@Test | ||
public void testFuzz65274Eof() throws Exception { | ||
try (InputStream in = getClass().getResourceAsStream("/data/fuzz-65274.ion")) { | ||
ION_MAPPER.readTree(in); | ||
fail("Should not pass (invalid content)"); | ||
} catch (StreamReadException e) { | ||
assertThat(e.getMessage(), Matchers.containsString("Corrupt Number value to decode")); | ||
} | ||
} | ||
} |
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,3 @@ | ||
n | ||
|
||
null.int����~���ttttt(�t�740���������n����66}tt |
Binary file not shown.
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
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