Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cve 2020 35381 #221

Merged
merged 2 commits into from Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion parser.go
Expand Up @@ -308,7 +308,11 @@ func searchKeys(data []byte, keys ...string) int {
case '[':
// If we want to get array element by index
if keyLevel == level && keys[level][0] == '[' {
aIdx, err := strconv.Atoi(keys[level][1 : len(keys[level])-1])
var keyLen = len(keys[level])
if keyLen < 3 || keys[level][0] != '[' || keys[level][keyLen-1] != ']' {
return -1
}
aIdx, err := strconv.Atoi(keys[level][1 : keyLen-1])
if err != nil {
return -1
}
Expand Down
12 changes: 12 additions & 0 deletions parser_test.go
Expand Up @@ -988,6 +988,18 @@ var getStringTests = []GetTest{
path: []string{"c"},
isErr: true,
},
{
desc: `empty array index`,
json: `[""]`,
path: []string{"[]"},
isFound: false,
},
{
desc: `malformed array index`,
json: `[""]`,
path: []string{"["},
isFound: false,
},
}

var getUnsafeStringTests = []GetTest{
Expand Down