use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class Fuzz32339_7BitBinaryTest method testInvalid7BitBinary.
// Test with negative length indicator (due to overflow) -- CF-32339
public void testInvalid7BitBinary() throws Exception {
final byte[] input0 = new byte[] { // smile signature
0x3A, // smile signature
0x29, // smile signature
0x0A, // smile signature
0x00, // binary, 7-bit encoded
(byte) 0xE8, 0x35, 0x20, 0x20, // 5 byte VInt for 0x7fe4083f (close to Integer.MAX_VALUE)
0x20, // 5 byte VInt for 0x7fe4083f (close to Integer.MAX_VALUE)
(byte) 0xFF };
// 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 (StreamReadException e) {
verifyException(e, "Overflow in VInt (current token VALUE_EMBEDDED_OBJECT");
verifyException(e, "1st byte (0x35)");
}
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class Fuzz_265_32377_7BitBinaryTest method testInvalid7BitBinary.
// Test with maximum declared payload size -- CF-32377
public void testInvalid7BitBinary() throws Exception {
final byte[] input0 = new byte[] { // smile signature
0x3A, // smile signature
0x29, // smile signature
0x0A, // smile signature
0x00, // binary, 7-bit encoded
(byte) 0xE8, 0x0F, 0x7E, 0x20, // 5 byte VInt for 0x7fe4083f (close to Integer.MAX_VALUE)
0x20, // 5 byte VInt for 0x7fe4083f (close to Integer.MAX_VALUE)
(byte) 0xFF };
// 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 (StreamReadException e) {
verifyException(e, "Unexpected end-of-input for Binary value (7-bit)", "expected 2145650751 bytes (from 2452172287 encoded)", "only decoded 58226");
}
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class Fuzz_291_35932_TruncUTF8NameTest method testInvalid7BitBinary.
// Test with maximum declared payload size -- CF-32377
public void testInvalid7BitBinary() throws Exception {
final byte[] input = readResource("/data/clusterfuzz-smile-35932.smile");
try (JsonParser p = MAPPER.createParser(input)) {
assertToken(JsonToken.START_OBJECT, p.nextToken());
p.nextToken();
fail("Should not pass");
} catch (StreamReadException e) {
verifyException(e, "Truncated UTF-8 character in Short Unicode Name (36 bytes)");
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class UncaughtExceptionsTest method testUncaughtException302.
// [dataformats-binary#302]
@Test
public void testUncaughtException302() throws Exception {
URL poc = getClass().getResource("/data/issue-302.ion");
try {
MAPPER.readTree(poc);
fail("Should not pass with invalid content");
} catch (StreamReadException e) {
verifyException(e, "Invalid embedded TIMESTAMP");
}
}
use of com.fasterxml.jackson.core.exc.StreamReadException in project jackson-dataformats-binary by FasterXML.
the class ParseIncompleteArray240Test method testIncompleteMarkerBasedObject.
public void testIncompleteMarkerBasedObject() throws Exception {
final byte[] input = { (byte) 0xBF };
try (CBORParser p = cborParser(F, input)) {
assertToken(JsonToken.START_OBJECT, p.nextToken());
try {
p.nextToken();
fail("Should NOT pass");
} catch (StreamReadException e) {
verifyException(e, "Unexpected end-of-input in Object value: expected a property or close marker");
}
}
}
Aggregations