-
-
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.
Fix issue in handling of corrupt Ion number (#429)
- Loading branch information
1 parent
fc337c4
commit 8039f96
Showing
4 changed files
with
77 additions
and
23 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
39 changes: 39 additions & 0 deletions
39
ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz_65062_VarintTest.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,39 @@ | ||
package com.fasterxml.jackson.dataformat.ion.fuzz; | ||
|
||
import java.io.InputStream; | ||
|
||
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.dataformat.ion.*; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
// https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65062 | ||
public class Fuzz_65062_VarintTest | ||
{ | ||
final IonObjectMapper MAPPER = IonObjectMapper.builder().build(); | ||
|
||
@Test | ||
public void testFuzz65062_Varint() throws Exception { | ||
try (InputStream in = getClass().getResourceAsStream("/data/fuzz-65062.ion")) { | ||
try (JsonParser p = MAPPER.createParser(in)) { | ||
assertEquals(JsonToken.START_ARRAY, p.nextToken()); | ||
|
||
while (p.nextToken() == JsonToken.VALUE_NUMBER_FLOAT) { | ||
p.getDecimalValue(); | ||
} | ||
assertEquals(JsonToken.END_ARRAY, p.nextToken()); | ||
} | ||
fail("Should not pass (invalid content)"); | ||
} catch (StreamReadException e) { | ||
// 21-Dec-2023, tatu: Not 100% sure why we won't get Number-specific fail but: | ||
assertThat(e.getMessage(), Matchers.containsString("Corrupt content to decode; underlying failure")); | ||
} | ||
} | ||
} |
Binary file not shown.