Skip to content
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

Safer way to handle unlock command of cli_wallet #1171 #82

Merged
merged 5 commits into from
Oct 28, 2018

Conversation

cogutvalera
Copy link
Member

@pmconrad
Copy link

Please bump editline to latest upstream master.

Note: we previously didn't use an editline release version either. Should be ok.

@cogutvalera
Copy link
Member Author

ok sure ! going to bump now ! Thanks !

@cogutvalera
Copy link
Member Author

tested all after bump and it works as expected on my side

src/rpc/cli.cpp Outdated
namespace fc { namespace rpc {

static std::string& cli_regex_secret()
{
static std::string* regex_secret = new std::string();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use new operator here. Just let regex_secret be a std::string and return that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok ! Thanks !

src/rpc/cli.cpp Outdated
@@ -87,9 +100,11 @@ void cli::run()
{
break;
}
std::cout << line << "\n";

std::cout << "\n";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should also be removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok ! Thanks !

src/rpc/cli.cpp Outdated
*/
static int cli_check_secret(const char *source)
{
boost::regex expr{cli_regex_secret()};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will re-parse the regex on every invocation. This is inefficient, it should only be parsed once when set_regex_secret is called.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sure ! Thanks !

src/rpc/cli.cpp Outdated
{
static std::string* regex_secret = new std::string();
return *regex_secret;
static boost::regex* regex_expr = new boost::regex();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still use new operator.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boost::regex must be initialized, it cannot be null

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without new operator we will have SEGFAULT

./programs/cli_wallet/cli_wallet --server-rpc-endpoint=wss://node.bitshares.eu
Logging RPC to file: logs/rpc/rpc.log
687810ms th_a       main.cpp:147                  main                 ] key_to_wif( committee_private_key ): 5KCBDTcyDqzsqehcb52tW5nU6pXife6V2rX9Yf7c3saYSzbDZ5W
687811ms th_a       main.cpp:151                  main                 ] nathan_pub_key: BTS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
687811ms th_a       main.cpp:152                  main                 ] key_to_wif( nathan_private_key ): 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
687814ms th_a       main.cpp:199                  main                 ] wdata.ws_server: wss://node.bitshares.eu
688461ms th_a       main.cpp:204                  main                 ] wdata.ws_user:  wdata.ws_password:
Segmentation fault (core dumped)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to remove the * as well of course.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sure, I will not use pointer, will fix it now. Thanks !

@pmconrad pmconrad merged commit acfe075 into bitshares:master Oct 28, 2018
@cogutvalera
Copy link
Member Author

Thank you !

crypto-ape pushed a commit to crypto-ape/bitshares-fc that referenced this pull request Oct 31, 2018
Safer way to handle unlock command of cli_wallet #1171
cogutvalera added a commit to cogutvalera/bitshares-fc that referenced this pull request Nov 18, 2018
While issue bitshares/bitshares-core#1171 is hold on and open we need to revert these both PRs to avoid compilation errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants