Skip to content

Commit c40bb51

Browse files
committed
Add bounds-checks to UTF8JsonGenerator.writeRaw(...)
1 parent be58a66 commit c40bb51

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/java/com/fasterxml/jackson/core/json/UTF8JsonGenerator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,15 @@ public void writeRaw(String text) throws IOException {
671671
public void writeRaw(String text, int offset, int len) throws IOException
672672
{
673673
final char[] buf = _charBuffer;
674-
final int cbufLen = buf.length;
675674

675+
// 03-Aug-2022, tatu: Maybe need to do bounds checks first (found by Fuzzer)
676+
if ((offset < 0) || (len < 0) || (offset+len) > text.length()) {
677+
_reportError(String.format(
678+
"Invalid 'offset' (%d) and/or 'len' (%d) arguments for String of length %d",
679+
offset, len, text.length()));
680+
}
681+
682+
final int cbufLen = buf.length;
676683
// minor optimization: see if we can just get and copy
677684
if (len <= cbufLen) {
678685
text.getChars(offset, offset+len, buf, 0);

0 commit comments

Comments
 (0)