-
-
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.
Fixed #260 (lazy byte[] allocation for longer binary payloads)
- Loading branch information
1 parent
9b82247
commit 5740026
Showing
8 changed files
with
116 additions
and
11 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
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
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
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
43 changes: 43 additions & 0 deletions
43
smile/src/test/java/com/fasterxml/jackson/dataformat/smile/fuzz/Fuzz32180BinaryTest.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,43 @@ | ||
package com.fasterxml.jackson.dataformat.smile.fuzz; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.util.Arrays; | ||
|
||
import com.fasterxml.jackson.core.io.JsonEOFException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import com.fasterxml.jackson.dataformat.smile.BaseTestForSmile; | ||
|
||
// For [dataformats-binary#] | ||
public class Fuzz32180BinaryTest extends BaseTestForSmile | ||
{ | ||
private final ObjectMapper MAPPER = smileMapper(); | ||
|
||
// Payload: | ||
public void testInvalidBinary() throws Exception | ||
{ | ||
final byte[] input0 = new byte[] { | ||
0x3A, 0x29, 0x0A, 0x00, // smile signature | ||
(byte) 0xFD, // raw binary | ||
0x0F, 0x7E, 0x20, | ||
0x20, (byte) 0xFF, // 5 byte VInt for 0x7fe4083f (close to Integer.MAX_VALUE) | ||
// and one byte of binary payload | ||
0x00 | ||
}; | ||
// Let's expand slightly to avoid too early detection, ensure that we are | ||
// not only checking completely missing payload or such | ||
final byte[] input = Arrays.copyOf(input0, 65 * 1024); | ||
|
||
try (ByteArrayInputStream bytes = new ByteArrayInputStream(input)) { | ||
try { | ||
/*JsonNode root =*/ MAPPER.readTree(bytes); | ||
} catch (JsonEOFException e) { | ||
verifyException(e, "Unexpected end-of-input for Binary value: expected 2145650751 bytes, only found 66550"); | ||
} catch (OutOfMemoryError e) { | ||
// Just to make it easier to see on fail (not ideal but better than nothing) | ||
e.printStackTrace(); | ||
throw e; | ||
} | ||
} | ||
} | ||
} |