-
-
Notifications
You must be signed in to change notification settings - Fork 768
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
819e064
commit e1e1699
Showing
3 changed files
with
54 additions
and
3 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
50 changes: 50 additions & 0 deletions
50
src/test/java/com/fasterxml/jackson/core/fuzz/Fuzz61198_1169_NumberParseTest.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,50 @@ | ||
package com.fasterxml.jackson.core.fuzz; | ||
|
||
import com.fasterxml.jackson.core.*; | ||
import com.fasterxml.jackson.core.json.JsonReadFeature; | ||
|
||
// For | ||
// | ||
// * [core#1169], | ||
// * https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61198 | ||
public class Fuzz61198_1169_NumberParseTest extends BaseTest | ||
{ | ||
// NOTE! Not enough to enable just first, but both it seem | ||
private final JsonFactory JSON_F = JsonFactory.builder() | ||
.enable(JsonReadFeature.ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS) | ||
.enable(JsonReadFeature.ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS) | ||
.build(); | ||
|
||
public void testLeadingPlusSignMalformedBytes() throws Exception { | ||
_testLeadingPlusMalformed(JSON_F, MODE_INPUT_STREAM); | ||
_testLeadingPlusMalformed(JSON_F, MODE_INPUT_STREAM_THROTTLED); | ||
} | ||
|
||
public void testLeadingPlusSignMalformedReader() throws Exception { | ||
_testLeadingPlusMalformed(JSON_F, MODE_READER); | ||
_testLeadingPlusMalformed(JSON_F, MODE_READER_THROTTLED); | ||
} | ||
|
||
public void testLeadingPlusSignMalformedOther() throws Exception { | ||
_testLeadingPlusMalformed(JSON_F, MODE_DATA_INPUT); | ||
} | ||
|
||
private void _testLeadingPlusMalformed(JsonFactory f, int mode) throws Exception | ||
{ | ||
// But also, invalid case: | ||
try (JsonParser p = createParser(f, mode, "[ +X 1 ")) { | ||
assertToken(JsonToken.START_ARRAY, p.nextToken()); | ||
try { | ||
JsonToken t = p.nextToken(); | ||
assertToken(JsonToken.VALUE_NUMBER_INT, t); | ||
// Either one works: | ||
// p.getNumberType(); | ||
p.getIntValue(); | ||
fail("Should not pass, got: "+t); | ||
} catch (JsonParseException e) { | ||
verifyException(e, "Unexpected character ('X' (code 88"); | ||
} | ||
} | ||
} | ||
|
||
} |