Skip to content

Commit b5b3a3a

Browse files
committed
Try fixing #437
1 parent bf8d729 commit b5b3a3a

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,9 @@ public JsonToken nextToken() throws IOException
593593
} catch (IonException e) {
594594
return _reportCorruptContent(e);
595595

596-
} catch (IndexOutOfBoundsException | AssertionError e) {
597-
// [dataformats-binary#420]: IonJava leaks IOOBEs so:
596+
// } catch (AssertionError | IndexOutOfBoundsException | NullPointerException e) {
597+
} catch (AssertionError | IndexOutOfBoundsException e) {
598+
// [dataformats-binary#420]: IonJava leaks IOOBEs, catch
598599
// [dataformats-binary#432]: AssertionError if we're trying to get the text
599600
// with a symbol id less than or equals to 0.
600601
return _reportCorruptContent(e);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.fasterxml.jackson.dataformat.ion.fuzz;
2+
3+
import java.io.*;
4+
5+
import org.hamcrest.Matchers;
6+
import org.junit.Test;
7+
8+
import com.fasterxml.jackson.core.JsonParser;
9+
import com.fasterxml.jackson.core.JsonToken;
10+
import com.fasterxml.jackson.core.exc.StreamReadException;
11+
import com.fasterxml.jackson.databind.ObjectMapper;
12+
import com.fasterxml.jackson.dataformat.ion.*;
13+
14+
import static org.hamcrest.MatcherAssert.assertThat;
15+
import static org.junit.Assert.assertEquals;
16+
import static org.junit.Assert.fail;
17+
18+
// [dataformats-binary#437]
19+
public class Fuzz437_65452_NPETest
20+
{
21+
private final ObjectMapper ION_MAPPER = new IonObjectMapper();
22+
23+
@Test
24+
public void testFuzz65452Eof() throws Exception {
25+
try (InputStream in = getClass().getResourceAsStream("/data/fuzz-65452.ion")) {
26+
try (JsonParser p = ION_MAPPER.createParser(in)) {
27+
assertEquals(JsonToken.VALUE_FALSE, p.nextToken());
28+
}
29+
fail("Should not pass (invalid content)");
30+
} catch (StreamReadException e) {
31+
assertThat(e.getMessage(), Matchers.containsString("Corrupt content to decode"));
32+
}
33+
}
34+
}
26 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)