Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 6, 2023
2 parents 702c2ba + 97f88da commit 1429083
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package tools.jackson.datatype.eclipsecollections;

import static org.junit.Assert.assertTrue;

import org.junit.Assert;
import org.junit.Test;

import org.eclipse.collections.api.map.primitive.MutableCharCharMap;

import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.exc.MismatchedInputException;

/**
* Unit tests for verifying the fixes for OSS-Fuzz issues
* work as expected
* (see [datatypes-collections#124]).
*/
public class Fuzz124_64629Test extends ModuleTestBase
{
private final ObjectMapper MAPPER = mapperWithModule();

@Test
public void testOSSFuzzIssue64629() throws Exception
{
// Invalid token {"x?":[x?]: where ? is not ascii characters
final char[] invalid = {123, 34, 824, 34, 58, 91, 120, 7, 93};

MismatchedInputException e = Assert.assertThrows(
MismatchedInputException.class,
() -> MAPPER.readValue(new String(invalid), MutableCharCharMap.class));
assertTrue(e.getMessage().contains("Cannot convert a JSON Null into a char element of map"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,16 @@ protected T _deserializeContents(JsonParser p, DeserializationContext ctxt)
continue;
}
value = _resolveNullToValue(ctxt);
if (value == null) {
ctxt.reportInputMismatch(valueDes,
"Guava `ImmutableCollection`s cannot contain `null`s");
}
} else if (typeDeser == null) {
value = valueDes.deserialize(p, ctxt);
} else {
value = valueDes.deserializeWithType(p, ctxt, typeDeser);
}

builder.add(value);
}
// No class outside of the package will be able to subclass us,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package tools.jackson.datatype.guava.fuzz;

import org.junit.Assert;

import tools.jackson.core.type.TypeReference;

import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.exc.MismatchedInputException;
import tools.jackson.datatype.guava.ModuleTestBase;

import com.google.common.collect.ImmutableSortedMultiset;

/**
* Unit tests for verifying the fixes for OSS-Fuzz issues
* work as expected
* (see [datatypes-collections#124]).
*/
public class Fuzz124_64610Test extends ModuleTestBase
{
private final ObjectMapper MAPPER = mapperWithModule();

public void testOSSFuzzIssue64610() throws Exception
{
final TypeReference<?> ref = new TypeReference<ImmutableSortedMultiset<String>>() {};
MismatchedInputException e = Assert.assertThrows(
MismatchedInputException.class,
() -> MAPPER.readValue("[null]", ref));
assertTrue(e.getMessage().contains("Guava `ImmutableCollection`s cannot contain `null`s"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public char key(DeserializationContext ctx, String key)

public char value(DeserializationContext ctx, JsonParser parser) throws JacksonException {
String valueAsString = parser.getValueAsString();
if (valueAsString == null) {
ctx.reportInputMismatch(char.class,
"Cannot convert a JSON Null into a char element of map");
}

if (valueAsString.length() != 1) {
ctx.reportInputMismatch(char.class,
"Cannot convert a JSON String of length %d into a char element of map",
Expand Down
7 changes: 6 additions & 1 deletion release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ Ethan McCue (@bowbahdoe)
* Reported #122: PCollections module info (`module-info.class`) incorrect
(2.15.4)

Wolff Bock von Wülfingen (wlfbck@github)
Wolff Bock von Wülfingen (@wlfbck)
* Reported #90: Cache Serialization serializes empty contents
(2.16.0)

Arthur Chan (@arthurscchan)
* Contributed #124: Some deserializers throw unexpected `NullPointerException`
when handling invalid input
(2.17.0)
4 changes: 3 additions & 1 deletion release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Active Maintainers:

2.17.0 (not yet released)

-
#124: Some deserializers throw unexpected `NullPointerException` when
handling invalid input
(contibuted by Arthur C)

2.16.0 (15-Nov-2023)

Expand Down

0 comments on commit 1429083

Please sign in to comment.