-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for 449: Unexpected IOOBE handling (#450)
- Loading branch information
1 parent
041d619
commit f0445ad
Showing
4 changed files
with
66 additions
and
7 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
45 changes: 45 additions & 0 deletions
45
...src/test/java/com/fasterxml/jackson/dataformat/avro/fuzz/AvroFuzz449_65618_IOOBETest.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,45 @@ | ||
package com.fasterxml.jackson.dataformat.avro.fuzz; | ||
|
||
import org.junit.Test; | ||
|
||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
import com.fasterxml.jackson.core.exc.StreamReadException; | ||
import com.fasterxml.jackson.dataformat.avro.AvroFactory; | ||
import com.fasterxml.jackson.dataformat.avro.AvroMapper; | ||
import com.fasterxml.jackson.dataformat.avro.AvroParser; | ||
import com.fasterxml.jackson.dataformat.avro.AvroSchema; | ||
import com.fasterxml.jackson.dataformat.avro.AvroTestBase; | ||
|
||
// [dataformats-binary#449] | ||
public class AvroFuzz449_65618_IOOBETest extends AvroTestBase | ||
{ | ||
@JsonPropertyOrder({ "name", "value" }) | ||
static class RootType { | ||
public String name; | ||
public int value; | ||
} | ||
|
||
@Test | ||
public void testFuzz65618IOOBE() throws Exception { | ||
final AvroFactory factory = AvroFactory.builderWithApacheDecoder().build(); | ||
final AvroMapper mapper = new AvroMapper(factory); | ||
|
||
final byte[] doc = { | ||
(byte) 2, (byte) 22, (byte) 36, (byte) 2, (byte) 0, | ||
(byte) 0, (byte) 8, (byte) 3, (byte) 3, (byte) 3, | ||
(byte) 122, (byte) 3, (byte) -24 | ||
}; | ||
|
||
final AvroSchema schema = mapper.schemaFor(RootType.class); | ||
try (AvroParser p = factory.createParser(doc)) { | ||
p.setSchema(schema); | ||
assertToken(JsonToken.START_OBJECT, p.nextToken()); | ||
assertToken(JsonToken.FIELD_NAME, p.nextToken()); | ||
p.nextToken(); | ||
fail("Should not pass (invalid content)"); | ||
} catch (StreamReadException e) { | ||
verifyException(e, "Malformed 2-byte UTF-8 character at the end of"); | ||
} | ||
} | ||
} |
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