From 9088d11c0cb638f623470970e2d10bbf143174cc Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 11 Jul 2025 12:46:56 +0100 Subject: [PATCH] use binary.BigEndian to be more explicit --- core/vm/contracts.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 19abca8a63..201aba837f 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -613,11 +613,18 @@ func (c *bigModExp) RequiredGas(input []byte) uint64 { } func (c *bigModExp) Run(input []byte) ([]byte, error) { - var ( - baseLen = new(uint256.Int).SetBytes(getData(input, 0, 32)).Uint64() - expLen = new(uint256.Int).SetBytes(getData(input, 32, 32)).Uint64() - modLen = new(uint256.Int).SetBytes(getData(input, 64, 32)).Uint64() - ) + // Extract lengths - they're 32-byte big-endian integers + // with the actual uint64 value in the last 8 bytes + var baseLen, expLen, modLen uint64 + if len(input) >= 32 { + baseLen = binary.BigEndian.Uint64(input[24:32]) + } + if len(input) >= 64 { + expLen = binary.BigEndian.Uint64(input[56:64]) + } + if len(input) >= 96 { + modLen = binary.BigEndian.Uint64(input[88:96]) + } if len(input) > 96 { input = input[96:] } else {