You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While testing the parsing of large integer strings, I discovered that the current implementation of JsonParser does not enforce a maximum length check for parsed strings. This can lead to Out-Of-Memory (OOM) errors when parsing excessively large inputs.
@TestpublicvoidtestIntegerStringExceedingMaxLength() {
intmaxStrDigits = 20000000;
// Construct a string that represents an integer with a length exceeding the maximum allowed limit.StringBuilderlargeIntStringBuilder = newStringBuilder("1");
for (inti = 0; i < maxStrDigits - 1; i++) {
largeIntStringBuilder.append("0");
}
StringlargeIntString = largeIntStringBuilder.toString();
// Attempt to parse the constructed string as JSON.JsonParser.JsonParserContextparserContext = newJsonParser.JsonParserContext(Object.class).withLazyNumbers();
try {
Objectfrom = parserContext.from(largeIntString);
fail("A ValueError should be raised because the integer string exceeds the maximum allowed length.");
} catch (JsonParserExceptione) {
// Expected behavior: An exception should be thrown to indicate the input exceeds the maximum allowed length.
}
}
Expected Behavior:
The JsonParser should enforce a maximum length check for parsed strings. If the input exceeds the allowed length, a JsonParserException should be thrown to prevent OOM errors.
Actual Behavior:
The JsonParser attempts to parse the excessively large string, which can trigger an OOM error, regardless of the length of the input.
Proposed Solution:
Introduce a configurable maximum length limit for parsed strings in the JsonParser. If the input exceeds this limit, a JsonParserException should be thrown with a descriptive error message. This would prevent OOM errors and improve the robustness of the parser.
The text was updated successfully, but these errors were encountered:
I’m working on a test migration experiment, and this test is one I’ve migrated from Gson. To save your time, could you simply confirm if the library indeed has this potential risk?
This is really important to me, and I’d truly appreciate your feedback. Thank you so much again for your time and support!
While testing the parsing of large integer strings, I discovered that the current implementation of JsonParser does not enforce a maximum length check for parsed strings. This can lead to Out-Of-Memory (OOM) errors when parsing excessively large inputs.
Expected Behavior:
The JsonParser should enforce a maximum length check for parsed strings. If the input exceeds the allowed length, a JsonParserException should be thrown to prevent OOM errors.
Actual Behavior:
The JsonParser attempts to parse the excessively large string, which can trigger an OOM error, regardless of the length of the input.
Proposed Solution:
Introduce a configurable maximum length limit for parsed strings in the JsonParser. If the input exceeds this limit, a JsonParserException should be thrown with a descriptive error message. This would prevent OOM errors and improve the robustness of the parser.
The text was updated successfully, but these errors were encountered: