-
-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #434: Add null check before accessing integer size #435
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e4a993c
Add null checking before accessing integer size
arthurscchan 4c47b75
Wrap the method call with try catch block
arthurscchan b0458aa
Fix for Java 8
arthurscchan e3378be
Fix comment
arthurscchan e8f425b
Merge branch '2.17' into 434-fix
cowtowncoder 2345a67
Refactor to avoid exception for `JsonParser.getNumberType()` on `Json…
cowtowncoder 4836dfd
Update release notes
cowtowncoder d11c407
Add a work-around for edge case wrt getNumberType()
cowtowncoder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
58 changes: 58 additions & 0 deletions
58
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,58 @@ | ||
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.fail; | ||
|
||
// [dataformats-binary#434 | ||
public class Fuzz434_65268_65274_NPETest | ||
{ | ||
@Test | ||
public void testFuzz65268() throws Exception { | ||
final IonFactory factory = | ||
IonFactory.builderForTextualWriters().build(); | ||
try (InputStream in = getClass().getResourceAsStream("/data/fuzz-65268.ion")) { | ||
try (JsonParser p = factory.createParser(in)) { | ||
p.nextToken(); | ||
p.getText(); | ||
p.nextTextValue(); | ||
p.getNumberType(); | ||
} | ||
fail("Should not pass (invalid content)"); | ||
} catch (StreamReadException e) { | ||
assertThat(e.getMessage(), Matchers.containsString("not integer")); | ||
} | ||
} | ||
|
||
@Test | ||
public void testFuzz65274() throws Exception { | ||
final ObjectMapper MAPPER = | ||
IonObjectMapper.builder( | ||
IonFactory.builderForBinaryWriters() | ||
.enable(IonParser.Feature.USE_NATIVE_TYPE_ID) | ||
.build()) | ||
.build(); | ||
|
||
try (InputStream in = getClass().getResourceAsStream("/data/fuzz-65274.ion")) { | ||
byte[] invalid = new byte[in.available()]; | ||
new DataInputStream(in).readFully(invalid); | ||
try (JsonParser p = MAPPER.getFactory().createParser(new ByteArrayInputStream(invalid))) { | ||
MAPPER.readTree(p); | ||
} | ||
fail("Should not pass (invalid content)"); | ||
} catch (StreamReadException e) { | ||
assertThat(e.getMessage(), Matchers.containsString("not integer")); | ||
} | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmh. I assume this is due to invalid/malformer content; and if so, should error out instead of quietly swallowing. Especially since it will fail couple of lines anyway. I can change that.