-
-
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 one obvious problem with "optimized" solution for #266
- Loading branch information
1 parent
b5aef16
commit d76566b
Showing
3 changed files
with
56 additions
and
6 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
44 changes: 44 additions & 0 deletions
44
.../src/test/java/com/fasterxml/jackson/dataformat/smile/fuzz/Fuzz32654ShortUnicodeTest.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,44 @@ | ||
package com.fasterxml.jackson.dataformat.smile.fuzz; | ||
|
||
import com.fasterxml.jackson.core.*; | ||
import com.fasterxml.jackson.core.exc.StreamReadException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import com.fasterxml.jackson.dataformat.smile.BaseTestForSmile; | ||
|
||
public class Fuzz32654ShortUnicodeTest extends BaseTestForSmile | ||
{ | ||
private final ObjectMapper MAPPER = smileMapper(); | ||
|
||
// [dataformats-binary#266] | ||
public void testInvalidShortUnicode() throws Exception | ||
{ | ||
/* | ||
final byte[] input = new byte[] { | ||
0x3A, 0x29, 0x0A, 0x00, // smile signature | ||
(byte) 0xFA, // START_OBJECT | ||
(byte) 0xC8, // short-unicode-name: 10 bytes (0x8 + 2), 6 chars | ||
(byte) 0xC8, (byte) 0xC8, | ||
(byte) 0xC8, (byte) 0xC8, (byte) 0xC8, 0x00, | ||
0x00, (byte) 0xF3, (byte) 0xA0, (byte) 0x81, | ||
(byte) 0x8A, // short-unicode-value: 12 bytes (0xA + 2) | ||
0x00, 0x01, 0x00, | ||
0x00, 0x00, 0x01, 0x01, | ||
0x00, 0x00, 0x04, (byte) 0xE5, | ||
0x04 | ||
}; | ||
*/ | ||
final byte[] input = readResource("/data/clusterfuzz-smile-32654.smile"); | ||
try (JsonParser p = MAPPER.createParser(input)) { | ||
assertToken(JsonToken.START_ARRAY, p.nextToken()); | ||
assertToken(JsonToken.VALUE_STRING, p.nextToken()); | ||
try { | ||
String text = p.getText(); | ||
fail("Should have failed, instead decoded String of "+text.length()+" chars"); | ||
} catch (StreamReadException e) { | ||
verifyException(e, "Invalid byte 0xB4 in short Unicode text"); | ||
} | ||
} | ||
} | ||
} |
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,7 @@ | ||
:) | ||
��:i | ||
4) | ||
1) | ||
z�*) | ||
�����a_) | ||
z�k_N� |