Skip to content

fixes missing protection of nil pointer dereference in scwallet #32186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions accounts/scwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ func (w *Wallet) selfDerive() {
continue
}
pairing := w.Hub.pairing(w)
if pairing == nil {
w.lock.Unlock()
reqc <- struct{}{}
continue
}

// Device lock obtained, derive the next batch of accounts
var (
Expand Down Expand Up @@ -631,13 +636,13 @@ func (w *Wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Accoun
}

if pin {
pairing := w.Hub.pairing(w)
pairing.Accounts[account.Address] = path
if err := w.Hub.setPairing(w, pairing); err != nil {
return accounts.Account{}, err
if pairing := w.Hub.pairing(w); pairing != nil {
pairing.Accounts[account.Address] = path
if err := w.Hub.setPairing(w, pairing); err != nil {
return accounts.Account{}, err
}
}
}

return account, nil
}

Expand Down Expand Up @@ -774,11 +779,11 @@ func (w *Wallet) SignTxWithPassphrase(account accounts.Account, passphrase strin
// It first checks for the address in the list of pinned accounts, and if it is
// not found, attempts to parse the derivation path from the account's URL.
func (w *Wallet) findAccountPath(account accounts.Account) (accounts.DerivationPath, error) {
pairing := w.Hub.pairing(w)
if path, ok := pairing.Accounts[account.Address]; ok {
return path, nil
if pairing := w.Hub.pairing(w); pairing != nil {
if path, ok := pairing.Accounts[account.Address]; ok {
return path, nil
}
}

// Look for the path in the URL
if account.URL.Scheme != w.Hub.scheme {
return nil, fmt.Errorf("scheme %s does not match wallet scheme %s", account.URL.Scheme, w.Hub.scheme)
Expand Down