Skip to content

Commit

Permalink
CLI wallet: avoid directly overwriting wallet file on exit bitshares#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nanomobile authored and cogutvalera committed Jul 30, 2018
1 parent 11d7faa commit a9e4d89
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libraries/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,10 +808,15 @@ class wallet_api_impl
//
// http://en.wikipedia.org/wiki/Most_vexing_parse
//
fc::ofstream outfile{ fc::path( wallet_filename ) };
fc::ofstream outfile{ fc::path( wallet_filename + ".backup" ) };
outfile.write( data.c_str(), data.length() );
outfile.flush();
outfile.close();

fc::rename( wallet_filename + ".backup", wallet_filename );

wlog( "successfully saved wallet to file ${fn}", ("fn", wallet_filename) );

disable_umask_protection();
}
catch(...)
Expand Down

0 comments on commit a9e4d89

Please sign in to comment.