-
Notifications
You must be signed in to change notification settings - Fork 16
Buffer overflow fix #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
davydsantos
wants to merge
5
commits into
netplex:master
Choose a base branch
from
davydsantos:bufferOverflowFix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1162f98
Port fix from v2.x related to Buffer overflow into v1.x
davydsantos 6f8d264
Adding incremental fix for unstacking objects in an array
davydsantos 6b05676
Adding \n
davydsantos 2bbe303
Update ParseException.java
davydsantos 33bbe18
Allowing changes on MAX size
davydsantos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
json-smart/src/test/java/net/minidev/json/test/TestOverflow.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package net.minidev.json.test; | ||
|
||
import net.minidev.json.JSONArray; | ||
import net.minidev.json.JSONValue; | ||
import net.minidev.json.parser.ParseException; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class TestOverflow { | ||
@Test | ||
public void stressTest() throws Exception { | ||
int size = 10000; | ||
StringBuilder sb = new StringBuilder(10 + size*4); | ||
for (int i=0; i < size; i++) { | ||
sb.append("{a:"); | ||
} | ||
sb.append("true"); | ||
for (int i=0; i < size; i++) { | ||
sb.append("}"); | ||
} | ||
String s = sb.toString(); | ||
try { | ||
JSONValue.parseWithException(s); | ||
} catch (ParseException e) { | ||
assertEquals(e.getErrorType(), ParseException.ERROR_UNEXPECTED_JSON_DEPTH); | ||
return; | ||
} | ||
assertTrue(false); | ||
} | ||
|
||
@Test | ||
public void shouldNotFailParsingArraysWith400Elements() throws Exception { | ||
int size = 400; | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("["); | ||
for (int i=0; i < size; i++) { | ||
sb.append("{a:true}"); | ||
if(i+1 < size) { | ||
sb.append(","); | ||
} | ||
} | ||
sb.append("]"); | ||
String s = sb.toString(); | ||
JSONArray array = (JSONArray) JSONValue.parseWithException(s); | ||
assertEquals(array.size(), size); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.