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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue-1368]: Panic in serializedPath.HasPrefix #1371

Merged
merged 11 commits into from
Apr 20, 2023
Prev Previous commit
Next Next commit
Update path.go
  • Loading branch information
dboehm-avalabs committed Apr 18, 2023
commit 45a32a515752f59466f1d02cf8d598a3fbca17b9
7 changes: 6 additions & 1 deletion x/merkledb/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ func (s SerializedPath) HasPrefix(prefix SerializedPath) bool {
return bytes.HasPrefix(s.Value, prefixValue)
}
reducedSize := len(prefixValue) - 1
if reducedSize < 0 {

// the input was invalid so just return false
if reducedSize < 0 ||
reducedSize >= len(prefixValue) ||
reducedSize >= len(s.Value) {
return false
}

// grab the last nibble in the prefix and serialized path
prefixRemainder := prefixValue[reducedSize] >> 4
valueRemainder := s.Value[reducedSize] >> 4
Expand Down