Ver Fonte

usbwallet: check returned error when decoding hexstr (#18056)

* usbwallet: check returned error when decoding hexstr

* Update accounts/usbwallet/ledger.go

Co-Authored-By: CoreyLin <514971757@qq.com>

* usbwallet: check hex decode error
Corey Lin há 7 anos atrás
pai
commit
b3be9b7cd8
1 ficheiros alterados com 3 adições e 1 exclusões
  1. 3 1
      accounts/usbwallet/ledger.go

+ 3 - 1
accounts/usbwallet/ledger.go

@@ -257,7 +257,9 @@ 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)
+	if _, err = hex.Decode(address[:], hexstr); err != nil {
+		return common.Address{}, err
+	}
 	return address, nil
 }