Skip to content

Commit

Permalink
change name check
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Aug 23, 2023
1 parent 6f3a9dc commit 50e1c44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ private final String parseName(int q1, int ch, int lastQuadBytes) throws IOExcep

private int[] growArrayWithNameLenCheck(int[] arr, int more) throws StreamConstraintsException {
// the following check will fail if the array is already bigger than is allowed for names
_streamReadConstraints.validateNameLength(arr.length);
_streamReadConstraints.validateNameLength(arr.length << 2);
return growArrayBy(_quadBuffer, more);
}

Expand Down Expand Up @@ -2118,7 +2118,7 @@ protected final String parseEscapedName(int[] quads, int qlen, int currQuad, int
}
quads[qlen++] = _padLastQuad(currQuad, currQuadBytes);
}
_streamReadConstraints.validateNameLength(qlen);
_streamReadConstraints.validateNameLength(qlen << 2);
String name = _symbols.findName(quads, qlen);
if (name == null) {
name = addName(quads, qlen, currQuadBytes);
Expand Down Expand Up @@ -2199,7 +2199,7 @@ protected String _handleOddName(int ch) throws IOException
}
quads[qlen++] = currQuad;
}
_streamReadConstraints.validateNameLength(qlen);
_streamReadConstraints.validateNameLength(qlen << 2);
String name = _symbols.findName(quads, qlen);
if (name == null) {
name = addName(quads, qlen, currQuadBytes);
Expand Down Expand Up @@ -2305,7 +2305,7 @@ protected String _parseAposName() throws IOException
}
quads[qlen++] = _padLastQuad(currQuad, currQuadBytes);
}
_streamReadConstraints.validateNameLength(qlen);
_streamReadConstraints.validateNameLength(qlen << 2);
String name = _symbols.findName(quads, qlen);
if (name == null) {
name = addName(quads, qlen, currQuadBytes);
Expand Down Expand Up @@ -2370,7 +2370,7 @@ private final String findName(int[] quads, int qlen, int lastQuad, int lastQuadB
_quadBuffer = quads = growArrayWithNameLenCheck(quads, quads.length);
}
quads[qlen++] = _padLastQuad(lastQuad, lastQuadBytes);
_streamReadConstraints.validateNameLength(qlen);
_streamReadConstraints.validateNameLength(qlen << 2);
String name = _symbols.findName(quads, qlen);
if (name == null) {
return addName(quads, qlen, lastQuadBytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2176,7 +2176,7 @@ private final JsonToken _parseEscapedName(int qlen, int currQuad, int currQuadBy
} else if (qlen == 0) { // rare, but may happen
return _fieldComplete("");
}
_streamReadConstraints.validateNameLength(qlen);
_streamReadConstraints.validateNameLength(qlen << 2);
String name = _symbols.findName(quads, qlen);
if (name == null) {
name = _addName(quads, qlen, currQuadBytes);
Expand Down Expand Up @@ -2275,7 +2275,7 @@ private JsonToken _finishUnquotedName(int qlen, int currQuad, int currQuadBytes)
}
quads[qlen++] = currQuad;
}
_streamReadConstraints.validateNameLength(qlen);
_streamReadConstraints.validateNameLength(qlen << 2);
String name = _symbols.findName(quads, qlen);
if (name == null) {
name = _addName(quads, qlen, currQuadBytes);
Expand Down Expand Up @@ -2373,7 +2373,7 @@ private JsonToken _finishAposName(int qlen, int currQuad, int currQuadBytes)
} else if (qlen == 0) { // rare case but possible
return _fieldComplete("");
}
_streamReadConstraints.validateNameLength(qlen);
_streamReadConstraints.validateNameLength(qlen << 2);
String name = _symbols.findName(quads, qlen);
if (name == null) {
name = _addName(quads, qlen, currQuadBytes);
Expand Down Expand Up @@ -2435,7 +2435,7 @@ protected final JsonToken _finishFieldWithEscape() throws IOException

private int[] growArrayWithNameLenCheck(int[] arr, int more) throws StreamConstraintsException {
// the following check will fail if the array is already bigger than is allowed for names
_streamReadConstraints.validateNameLength(arr.length);
_streamReadConstraints.validateNameLength(arr.length << 2);
return growArrayBy(_quadBuffer, more);
}

Expand Down

0 comments on commit 50e1c44

Please sign in to comment.