From 1253f2cc58422379cb55cbe695fda836efc2b084 Mon Sep 17 00:00:00 2001 From: RJ Catalano Date: Tue, 13 Jun 2017 18:50:00 -0500 Subject: [PATCH] accounts/abi: be very very very correct Signed-off-by: RJ Catalano --- accounts/abi/unpack.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go index e85621b1ec..cbd6fa85e6 100644 --- a/accounts/abi/unpack.go +++ b/accounts/abi/unpack.go @@ -166,10 +166,15 @@ func getBoolValue(b []byte) (bool, error) { return false, fmt.Errorf("abi: Improperly encoded boolean value.") } } - if uint(b[31]) == 1 { + switch uint(b[31]) { + case 0: + return false, nil + case 1: return true, nil + default: + return false, fmt.Errorf("abi: Improperly encoded boolean value.") } - return false, nil + } // toGoType parses the input and casts it to the proper type defined by the ABI