triedb/pathdb: fix 32-bit overflow in history trie node decoding

Use `math.MaxInt` instead of `math.MaxUint32` for size validation. On 32-bit systems, `int` is 32 bits, so values between `MaxInt32` and `MaxUint32` would pass the check but overflow to negative when cast to `int`, causing slice bounds panic.
This commit is contained in:
Tanvir 2026-04-17 21:02:25 +08:00
parent 573d94013c
commit 5bb29ba6f8

View file

@ -375,7 +375,7 @@ func decodeKeyEntry(keySection []byte, offset int) (uint64, uint64, []byte, int,
byteRead += nn
// Validate that the values can fit in an int to prevent overflow on 32-bit systems
if nShared > uint64(math.MaxUint32) || nUnshared > uint64(math.MaxUint32) || nValue > uint64(math.MaxUint32) {
if nShared > uint64(math.MaxInt) || nUnshared > uint64(math.MaxInt) || nValue > uint64(math.MaxInt) {
return 0, 0, nil, 0, errors.New("key/value size too large")
}