-
Notifications
You must be signed in to change notification settings - Fork 24
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
fix: security report fix #206
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,12 +61,13 @@ func ParseGrantKey(key []byte) (granterAddr, granteeAddr sdk.AccAddress, msgType | |
// key is of format: | ||
// <granterAddressLen (1 Byte)><granterAddress_Bytes><granteeAddressLen (1 Byte)><granteeAddress_Bytes><msgType_Bytes> | ||
kv.AssertKeyAtLeastLength(key, 2) | ||
granterAddrLen := key[0] | ||
// prevent granterAddrLen overflow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please dont change this, as we did not use this, let us keep consistent with cosmos-sdk. |
||
granterAddrLen := int(key[0]) | ||
kv.AssertKeyAtLeastLength(key, int(2+granterAddrLen)) | ||
granterAddr = sdk.AccAddress(key[1 : 1+granterAddrLen]) | ||
granteeAddrLen := int(key[1+granterAddrLen]) | ||
kv.AssertKeyAtLeastLength(key, 3+int(granterAddrLen+byte(granteeAddrLen))) | ||
granteeAddr = sdk.AccAddress(key[2+granterAddrLen : 2+granterAddrLen+byte(granteeAddrLen)]) | ||
kv.AssertKeyAtLeastLength(key, 3+granterAddrLen+granteeAddrLen) | ||
granteeAddr = sdk.AccAddress(key[2+granterAddrLen : 2+granterAddrLen+granteeAddrLen]) | ||
|
||
return granterAddr, granteeAddr, conv.UnsafeBytesToStr(key[2+granterAddrLen+byte(granteeAddrLen):]) | ||
return granterAddr, granteeAddr, conv.UnsafeBytesToStr(key[2+granterAddrLen+granteeAddrLen:]) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,9 @@ func stripRowID(indexKey []byte, secondaryIndexKey interface{}) (RowID, error) { | |
switch v := secondaryIndexKey.(type) { | ||
case []byte: | ||
searchableKeyLen := indexKey[0] | ||
if 1+int(searchableKeyLen) > len(indexKey) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please dont change this as we dont use it. |
||
return nil, fmt.Errorf("searchableKeyLen is out of bounds") | ||
} | ||
return indexKey[1+searchableKeyLen:], nil | ||
case string: | ||
searchableKeyLen := 0 | ||
|
@@ -91,8 +94,14 @@ func stripRowID(indexKey []byte, secondaryIndexKey interface{}) (RowID, error) { | |
break | ||
} | ||
} | ||
if 1+searchableKeyLen > len(indexKey) { | ||
return nil, fmt.Errorf("searchableKeyLen is out of bounds") | ||
} | ||
return indexKey[1+searchableKeyLen:], nil | ||
case uint64: | ||
if EncodedSeqLength > len(indexKey) { | ||
return nil, fmt.Errorf("EncodedSeqLength is out of bounds") | ||
} | ||
return indexKey[EncodedSeqLength:], nil | ||
default: | ||
return nil, fmt.Errorf("type %T not allowed as index key", v) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,12 +219,22 @@ func ParseValidatorQueueKey(bz []byte) (time.Time, int64, error) { | |
return time.Time{}, 0, fmt.Errorf("invalid prefix; expected: %X, got: %X", ValidatorQueueKey, prefix) | ||
} | ||
|
||
if prefixL+8 > len(bz) { | ||
return time.Time{}, 0, fmt.Errorf("timeBzl is out of bounds") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We dont use this, so no need to change it. |
||
} | ||
timeBzL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) | ||
|
||
if prefixL+8+int(timeBzL) > len(bz) { | ||
return time.Time{}, 0, fmt.Errorf("ts is out of bounds") | ||
} | ||
ts, err := sdk.ParseTimeBytes(bz[prefixL+8 : prefixL+8+int(timeBzL)]) | ||
if err != nil { | ||
return time.Time{}, 0, err | ||
} | ||
|
||
if prefixL+8+int(timeBzL) >= len(bz) { | ||
return time.Time{}, 0, fmt.Errorf("height is out of bounds") | ||
} | ||
height := sdk.BigEndianToUint64(bz[prefixL+8+int(timeBzL):]) | ||
|
||
return ts, int64(height), nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,11 +221,18 @@ func ParseValidatorQueueKey(bz []byte) (time.Time, int64, error) { | |
} | ||
|
||
timeBzL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) | ||
if prefixL+8+int(timeBzL) > len(bz) { | ||
return time.Time{}, 0, fmt.Errorf("ts is out of bounds") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So is here. |
||
} | ||
|
||
ts, err := sdk.ParseTimeBytes(bz[prefixL+8 : prefixL+8+int(timeBzL)]) | ||
if err != nil { | ||
return time.Time{}, 0, err | ||
} | ||
|
||
if prefixL+8+int(timeBzL) >= len(bz) { | ||
return time.Time{}, 0, fmt.Errorf("height is out of bounds") | ||
} | ||
height := sdk.BigEndianToUint64(bz[prefixL+8+int(timeBzL):]) | ||
|
||
return ts, int64(height), nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this.
It is ok if
PackageHeader
is wrong, as the protocol will handle this.