mirror of
https://github.com/monero-project/monero.git
synced 2024-12-28 20:46:14 -05:00
use load_file_to_string and exit with error on file read errors
This commit is contained in:
parent
7b2d27f89a
commit
c5baf30208
@ -808,9 +808,15 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
|||||||
}
|
}
|
||||||
else if (command_line::has_arg(vm, arg_password_file))
|
else if (command_line::has_arg(vm, arg_password_file))
|
||||||
{
|
{
|
||||||
std::ifstream pfs(command_line::get_arg(vm, arg_password_file));
|
std::string password;
|
||||||
std::string password((std::istreambuf_iterator<char>(pfs)),
|
bool r = epee::file_io_utils::load_file_to_string(command_line::get_arg(vm, arg_password_file),
|
||||||
(std::istreambuf_iterator<char>()));
|
password);
|
||||||
|
if (!r)
|
||||||
|
{
|
||||||
|
fail_msg_writer() << tr("the password file specified could not be read");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove line breaks the user might have inserted
|
// Remove line breaks the user might have inserted
|
||||||
password.erase(std::remove(password.begin() - 1, password.end(), '\n'), password.end());
|
password.erase(std::remove(password.begin() - 1, password.end(), '\n'), password.end());
|
||||||
password.erase(std::remove(password.end() - 1, password.end(), '\r'), password.end());
|
password.erase(std::remove(password.end() - 1, password.end(), '\r'), password.end());
|
||||||
|
Loading…
Reference in New Issue
Block a user