-
-
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.
- Loading branch information
1 parent
12eebda
commit 569b8ee
Showing
4 changed files
with
59 additions
and
4 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
35 changes: 35 additions & 0 deletions
35
...test/java/com/fasterxml/jackson/dataformat/cbor/fuzz/Fuzz289_35822_TruncatedNameTest.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,35 @@ | ||
package com.fasterxml.jackson.dataformat.cbor.fuzz; | ||
|
||
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.cbor.CBORTestBase; | ||
|
||
public class Fuzz289_35822_TruncatedNameTest extends CBORTestBase | ||
{ | ||
private final ObjectMapper MAPPER = cborMapper(); | ||
|
||
// As per https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35822 | ||
// ArrayIndexOutOfBoundsException when 2 out of 3 bytes available before | ||
// end-of-input | ||
public void testInvalidSplitUtf8Unit() throws Exception | ||
{ | ||
final byte[] input = new byte[] { | ||
(byte) 0xA6, // Object, 6 entries | ||
0x78, 0x02, // String (key), length 2 (non-canonical) | ||
(byte) 0xE6, (byte) 0x8B // broken UTF-8 codepoint | ||
}; | ||
|
||
try (JsonParser p = MAPPER.createParser(input)) { | ||
assertToken(JsonToken.START_OBJECT, p.nextToken()); | ||
try { | ||
assertToken(JsonToken.FIELD_NAME, p.nextToken()); | ||
fail("Should not pass"); | ||
} catch (StreamReadException e) { | ||
verifyException(e, "Truncated UTF-8"); | ||
verifyException(e, "byte 0xE6 at offset #0 indicated 2 more bytes needed"); | ||
} | ||
} | ||
} | ||
} |
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