From 5bb29ba6f8c103ea5bd6d608c1d28791e7ed166f Mon Sep 17 00:00:00 2001 From: Tanvir Date: Fri, 17 Apr 2026 21:02:25 +0800 Subject: [PATCH] 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. --- triedb/pathdb/history_trienode.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triedb/pathdb/history_trienode.go b/triedb/pathdb/history_trienode.go index 11d6112806..905018e563 100644 --- a/triedb/pathdb/history_trienode.go +++ b/triedb/pathdb/history_trienode.go @@ -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") }