Skip to content

Commit c473e1a

Browse files
committed
Yet more OSS-Fuzz induced try-catch:ing for IonParser
1 parent 937b637 commit c473e1a

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonParser.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,18 @@ public float getFloatValue() throws IOException {
397397
@Override
398398
public int getIntValue() throws IOException {
399399
_verifyIsNumberToken();
400-
return _reader.intValue();
400+
return _getIntValue();
401+
}
402+
403+
// @since 2.17
404+
private int _getIntValue() throws IOException {
405+
try {
406+
return _reader.intValue();
407+
} catch (IonException
408+
// 15-Jan-2024, tatu: other OSS-Fuzz tests suggest we need this:
409+
| ArrayIndexOutOfBoundsException e) {
410+
return _reportCorruptNumber(e);
411+
}
401412
}
402413

403414
@Override
@@ -453,8 +464,8 @@ public NumberType getNumberType() throws IOException
453464
size = _reader.getIntegerSize();
454465
} catch (IonException e) {
455466
return _reportCorruptNumber(e);
456-
} catch (NullPointerException e) {
457-
return _reportCorruptContent(e);
467+
} catch (AssertionError | NullPointerException e) {
468+
return _reportCorruptNumber(e);
458469
}
459470
if (size == null) {
460471
_reportError("Current token (%s) not integer", _currToken);
@@ -502,7 +513,7 @@ public Number getNumberValue() throws IOException {
502513
if (nt != null) {
503514
switch (nt) {
504515
case INT:
505-
return _reader.intValue();
516+
return _getIntValue();
506517
case LONG:
507518
return _getLongValue();
508519
case FLOAT:

ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz434_65268_65274_NPETest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void testFuzz65274Malformed() throws Exception {
4343
ION_MAPPER.readTree(new ByteArrayInputStream(doc));
4444
fail("Should not pass (invalid content)");
4545
} catch (StreamReadException e) {
46-
assertThat(e.getMessage(), Matchers.containsString("Corrupt content to decode"));
46+
assertThat(e.getMessage(), Matchers.containsString("Corrupt Number value to decode"));
4747
}
4848
}
4949

0 commit comments

Comments
 (0)