From 5b9d0e4f246148e386afdf55f2e150fb96ffe89c Mon Sep 17 00:00:00 2001 From: alex017 Date: Thu, 29 Jan 2026 22:42:01 +0100 Subject: [PATCH] Update history_trienode.go --- triedb/pathdb/history_trienode.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/triedb/pathdb/history_trienode.go b/triedb/pathdb/history_trienode.go index 05a43808c2..6385c90e55 100644 --- a/triedb/pathdb/history_trienode.go +++ b/triedb/pathdb/history_trienode.go @@ -352,6 +352,9 @@ func decodeHeader(data []byte) (*trienodeMetadata, []common.Hash, []uint32, []ui // the specified offset. func decodeKeyEntry(keySection []byte, offset int) (uint64, uint64, []byte, int, error) { var byteRead int + if offset < 0 || offset >= len(keySection) { + return 0, 0, nil, 0, fmt.Errorf("key offset out of bounds, offset: %d, section size: %d", offset, len(keySection)) + } // Resolve the length of shared key nShared, nn := binary.Uvarint(keySection[offset:]) // key length shared (varint)