Compare commits

...

3 Commits

  1. 21
      src/wallet/rpcdump.cpp

21
src/wallet/rpcdump.cpp

@ -479,6 +479,27 @@ UniValue importwallet_impl(const UniValue& params, bool fHelp, bool fImportZKeys
EnsureWalletIsUnlocked();
struct stat s;
if( stat(params[0].get_str().c_str(),&s) == 0 ) {
if( s.st_mode & S_IFDIR ) { // it's a directory
throw JSONRPCError(RPC_WALLET_ERROR, "Invalid wallet export file (directory)");
} else if( s.st_mode & S_IFREG ) { // it's a file
// The absolute smallest valid export file is a single taddr privkey with no
// newline and no comments. In practice, autogenerated files will be much larger
if(s.st_size < 51) {
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet export file is too small to be valid");
}
} else if( s.st_mode & S_IFLNK ) { // it's a symbolic link
// TODO: check filesize of symbolicly linked file
// for symlinks, size the length in bytes of the pathname contained in the symbolic link
// which is not what we want
} else { // something else, either a block/char/FIFO special file or socket, none of which are valid
throw JSONRPCError(RPC_WALLET_ERROR, "Invalid wallet export file (special)");
}
} else {
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet export file does not exist");
}
ifstream file;
file.open(params[0].get_str().c_str(), std::ios::in | std::ios::ate);
if (!file.is_open())

Loading…
Cancel
Save