Skip to content
New issue

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

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

Already on GitHub? # to your account

[p3] Parsing keystore file in an incorrect format causes unfriendly panic #1551

Closed
shilei-wang opened this issue Jun 11, 2019 · 2 comments
Closed
Assignees
Labels
bug Something isn't working crypto

Comments

@shilei-wang
Copy link
Contributor

shilei-wang commented Jun 11, 2019

Describe the bug
Try to recover a key from keystore , parse JSON file and encounter an empty object(like {})would cause panic output.

To Reproduce

  1. create an empty keystore, and save an empty object (like {}) in it.
  2. iriscli keys add x --recover --keystore=<keystore_path>

panic: interface conversion: interface {} is nil, not string [recovered]
panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
main.main.func1()
/Users/sherlock/go/src/github.com/irishub/cmd/iriscli/main.go:45 +0xb3
panic(0x4a753c0, 0xc000a7f830)
/usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5
github.com/irisnet/irishub/crypto/keystore.getKDFKey(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/sherlock/go/src/github.com/irishub/crypto/keystore/keystore.go:84 +0x67c
github.com/irisnet/irishub/crypto/keystore.decryptKey(0xc000122630, 0xc0000c2516, 0xa, 0x49e8a00, 0xc000122630, 0x0, 0x0, 0x4aae0e0)
/Users/sherlock/go/src/github.com/irishub/crypto/keystore/keystore.go:62 +0x270
github.com/irisnet/irishub/crypto/keystore.(*keyManager).recoveryFromKeyStore(0xc0009c0000, 0x7ffeefbffc79, 0x17, 0xc0000c2516, 0xa, 0x0, 0x0)
/Users/sherlock/go/src/github.com/irishub/crypto/keystore/keys.go:61 +0x1ce
github.com/irisnet/irishub/crypto/keystore.NewKeyStoreKeyManager(...)
/Users/sherlock/go/src/github.com/irishub/crypto/keystore/keys.go:44
github.com/irisnet/irishub/client/keys/cli.runAddCmd(0xc000b02d80, 0xc00045e750, 0x1, 0x3, 0x0, 0x0)
/Users/sherlock/go/src/github.com/irishub/client/keys/cli/add.go:170 +0xeb6
github.com/spf13/cobra.(*Command).execute(0xc000b02d80, 0xc00045e6c0, 0x3, 0x3, 0xc000b02d80, 0xc00045e6c0)
/Users/sherlock/go/pkg/mod/github.com/spf13/cobra@v0.0.1/command.go:698 +0x431
github.com/spf13/cobra.(*Command).ExecuteC(0x5612a40, 0xc000b0cd20, 0x0, 0x0)
/Users/sherlock/go/pkg/mod/github.com/spf13/cobra@v0.0.1/command.go:783 +0x2ca
github.com/spf13/cobra.(*Command).Execute(...)
/Users/sherlock/go/pkg/mod/github.com/spf13/cobra@v0.0.1/command.go:736
github.com/tendermint/tendermint/libs/cli.Executor.Execute(0x5612a40, 0x4d072e0, 0x0, 0xc00087a980)
/Users/sherlock/go/pkg/mod/github.com/irisnet/tendermint@v0.22.3-0.20190527110704-aff684d6c906/libs/cli/setup.go:89 +0x3c
main.main()
/Users/sherlock/go/src/github.com/irishub/cmd/iriscli/main.go:272 +0x1b15

@shilei-wang shilei-wang added the bug Something isn't working label Jun 11, 2019
@chengwenxi chengwenxi self-assigned this Jun 11, 2019
@haifengxi
Copy link
Contributor

Related: #1493

@haifengxi haifengxi changed the title [p3] Parse keystore JSON file in an incorrect format would cause unfriendly panic output [p3] Parsing keystore file in an incorrect format causes unfriendly panic Jun 11, 2019
@shilei-wang
Copy link
Contributor Author

Verify fixed

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working crypto
Projects
None yet
Development

No branches or pull requests

3 participants