From 26bc048feacfa4b313258142afd7562b7014712f Mon Sep 17 00:00:00 2001 From: kdeme Date: Fri, 19 Jul 2019 10:56:47 +0200 Subject: [PATCH] Fix possible IndexError in ecrecover --- nimbus/vm/precompiles.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nimbus/vm/precompiles.nim b/nimbus/vm/precompiles.nim index 439ac11f5..535eee183 100644 --- a/nimbus/vm/precompiles.nim +++ b/nimbus/vm/precompiles.nim @@ -21,7 +21,7 @@ proc getSignature*(computation: BaseComputation): (array[32, byte], Signature) = template data: untyped = computation.msg.data var bytes: array[65, byte] let maxPos = min(data.high, 127) - if maxPos >= 31: + if maxPos >= 63: # extract message hash result[0][0..31] = data[0..31] if maxPos >= 127: @@ -31,7 +31,7 @@ proc getSignature*(computation: BaseComputation): (array[32, byte], Signature) = elif maxPos >= 64: bytes[0..(maxPos-64)] = data[64..maxPos] else: - result[0][0..maxPos] = data[0..maxPos] + raise newException(ValidationError, "Invalid V in getSignature") var VOK = true let v = data[63]