aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Hirschmann <fabian@hirschmann.email>2016-01-09 19:11:34 +0100
committerFabian Hirschmann <fabian@hirschmann.email>2016-01-09 19:11:34 +0100
commitc5baf30208817ebb6f07541ed49f9067b910272a (patch)
tree072af358dab40b4d3c580d4f3f233ab68650fcad
parentremove new lines at the end of the password only (diff)
downloadmonero-c5baf30208817ebb6f07541ed49f9067b910272a.tar.xz
use load_file_to_string and exit with error on file read errors
-rw-r--r--src/simplewallet/simplewallet.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 2e1337ce0..2484cd3a5 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -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))
{
- std::ifstream pfs(command_line::get_arg(vm, arg_password_file));
- std::string password((std::istreambuf_iterator<char>(pfs)),
- (std::istreambuf_iterator<char>()));
+ std::string password;
+ bool r = epee::file_io_utils::load_file_to_string(command_line::get_arg(vm, arg_password_file),
+ 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
password.erase(std::remove(password.begin() - 1, password.end(), '\n'), password.end());
password.erase(std::remove(password.end() - 1, password.end(), '\r'), password.end());