Skip to content

Commit c9f7296

Browse files
committed
Add panic check for start length
1 parent 9fafc88 commit c9f7296

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/rawdb/accessors_state_sync.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ func UnpackSyncSegmentKey(keyBytes []byte) (common.Hash, []byte) {
105105

106106
// packSyncSegmentKey packs root and account into a key for storage in db.
107107
func packSyncSegmentKey(root common.Hash, start []byte) []byte {
108-
bytes := make([]byte, len(syncSegmentsPrefix)+common.HashLength+len(start))
108+
if len(start) != common.HashLength {
109+
panic("start must be 32 bytes")
110+
}
111+
bytes := make([]byte, syncSegmentsKeyLength)
109112
copy(bytes, syncSegmentsPrefix)
110113
copy(bytes[len(syncSegmentsPrefix):], root[:])
111114
copy(bytes[len(syncSegmentsPrefix)+common.HashLength:], start)

0 commit comments

Comments
 (0)