Skip to content

Commit

Permalink
Backport #418 fix to 2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 20, 2017
1 parent 444efa0 commit 144ba1f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ JSON library.

#304: Optimize `NumberOutput.outputLong()` method

2.8.11 (not yet released)

#418: ArrayIndexOutOfBoundsException from UTF32Reader.read on invalid input
(reported, contributed fix for by pfitzsimons-r7@github)

2.8.10 (24-Aug-2017)

No changes since 2.8.9
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/fasterxml/jackson/core/io/UTF32Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public int read(char[] cbuf, int start, int len) throws IOException {
}

// 02-Jun-2017, tatu: Must ensure we don't try to read past buffer end:
final int _lastValidInputStart = (_length - 3);
final int lastValidInputStart = (_length - 4);

main_loop:
while (outPtr < outEnd) {
Expand Down Expand Up @@ -168,7 +168,7 @@ public int read(char[] cbuf, int start, int len) throws IOException {
}
}
cbuf[outPtr++] = (char) lo;
if (_ptr > _lastValidInputStart) {
if (_ptr > lastValidInputStart) {
break main_loop;
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/com/fasterxml/jackson/core/read/UTF32ParseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,16 @@ public void testSimpleInvalidUTF32() throws Exception
}
parser.close();
}

public void testSimpleSevenNullBytes() throws Exception {
byte[] data = new byte[7];
JsonParser parser = FACTORY.createParser(/*ObjectReadContext.empty(), */data);
try {
parser.nextToken();
fail("Should not pass");
} catch (JsonParseException e) {
verifyException(e, "Illegal character ((CTRL-CHAR, code 0))");
}
parser.close();
}
}

0 comments on commit 144ba1f

Please sign in to comment.