Skip to content

Fix issue 458: Add null checking #459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2224,6 +2224,9 @@ protected void convertNumberToBigDecimal() throws IOException
// Let's parse from String representation, to avoid rounding errors that
//non-decimal floating operations would incur
final String text = getText();
if (text == null) {
throw _constructReadException("No more values");
}
streamReadConstraints().validateFPLength(text.length());
_numberBigDecimal = NumberInput.parseBigDecimal(
text, isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.fasterxml.jackson.dataformat.cbor.fuzz;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.exc.StreamReadException;

import com.fasterxml.jackson.databind.ObjectMapper;

import com.fasterxml.jackson.dataformat.cbor.CBORTestBase;

public class CBORFuzz458_65768_NPETest extends CBORTestBase
{
private final ObjectMapper MAPPER = cborMapper();

public void testInvalidText() throws Exception
{
final byte[] input = readResource("/data/clusterfuzz-cbor-65768.cbor");
try (JsonParser p = MAPPER.createParser(input)) {
try {
p.nextTextValue();
p.getIntValue();
p.nextTextValue();
p.nextTextValue();
p.nextTextValue();
p.nextTextValue();
p.nextTextValue();
p.nextTextValue();
p.nextTextValue();
p.nextTextValue();
p.nextTextValue();
p.getFloatValue();
p.getDecimalValue();
fail("Should not reach here (invalid input)");
} catch (StreamReadException e) {
verifyException(e, "No more values");
}
}
}
}
Binary file not shown.