From b172afd1cc8015a707719e8560e83239613c1f97 Mon Sep 17 00:00:00 2001 From: Lin Corey Date: Thu, 8 Nov 2018 10:48:02 +0800 Subject: [PATCH 1/3] usbwallet: check returned error when decoding hexstr --- accounts/usbwallet/ledger.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/accounts/usbwallet/ledger.go b/accounts/usbwallet/ledger.go index 7d5f67908de2..9b7ca181fcb9 100644 --- a/accounts/usbwallet/ledger.go +++ b/accounts/usbwallet/ledger.go @@ -257,7 +257,10 @@ func (w *ledgerDriver) ledgerDerive(derivationPath []uint32) (common.Address, er // Decode the hex sting into an Ethereum address and return var address common.Address - hex.Decode(address[:], hexstr) + _, err = hex.Decode(address[:], hexstr) + if err != nil { + return common.Address{}, err + } return address, nil } From 7039c5664995af5ead080ccc97f9bc63b2cf0ccd Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 11 Dec 2018 10:36:04 +0800 Subject: [PATCH 2/3] Update accounts/usbwallet/ledger.go Co-Authored-By: CoreyLin <514971757@qq.com> --- accounts/usbwallet/ledger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/usbwallet/ledger.go b/accounts/usbwallet/ledger.go index 9b7ca181fcb9..13604a4a6a17 100644 --- a/accounts/usbwallet/ledger.go +++ b/accounts/usbwallet/ledger.go @@ -258,7 +258,7 @@ func (w *ledgerDriver) ledgerDerive(derivationPath []uint32) (common.Address, er // Decode the hex sting into an Ethereum address and return var address common.Address _, err = hex.Decode(address[:], hexstr) - if err != nil { + if _, err = hex.Decode(address[:], hexstr); err != nil { return common.Address{}, err } return address, nil From 199d6b8d10527b8c005ecc1c9f233d9977e660dc Mon Sep 17 00:00:00 2001 From: CoreyLin <514971757@qq.com> Date: Tue, 11 Dec 2018 10:41:07 +0800 Subject: [PATCH 3/3] usbwallet: check hex decode error --- accounts/usbwallet/ledger.go | 1 - 1 file changed, 1 deletion(-) diff --git a/accounts/usbwallet/ledger.go b/accounts/usbwallet/ledger.go index 13604a4a6a17..c30903b5b769 100644 --- a/accounts/usbwallet/ledger.go +++ b/accounts/usbwallet/ledger.go @@ -257,7 +257,6 @@ func (w *ledgerDriver) ledgerDerive(derivationPath []uint32) (common.Address, er // Decode the hex sting into an Ethereum address and return var address common.Address - _, err = hex.Decode(address[:], hexstr) if _, err = hex.Decode(address[:], hexstr); err != nil { return common.Address{}, err }