mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-19 05:45:05 +01:00
wallettool: Check that the dumpfile checksum is the correct size
After parsing the checksum, make sure that it is the size that we expect it to be.
This commit is contained in:
parent
887796a5ff
commit
ac617cc141
@ -214,6 +214,11 @@ bool CreateFromDump(const std::string& name, const fs::path& wallet_path, biling
|
||||
|
||||
if (key == "checksum") {
|
||||
std::vector<unsigned char> parsed_checksum = ParseHex(value);
|
||||
if (parsed_checksum.size() != checksum.size()) {
|
||||
error = Untranslated("Error: Checksum is not the correct size");
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
std::copy(parsed_checksum.begin(), parsed_checksum.end(), checksum.begin());
|
||||
break;
|
||||
}
|
||||
|
@ -390,7 +390,11 @@ class ToolWalletTest(BitcoinTestFramework):
|
||||
bad_sum_wallet_dump = os.path.join(self.nodes[0].datadir, "wallet-bad_sum3.dump")
|
||||
dump_data["checksum"] = "2" * 10
|
||||
self.write_dump(dump_data, bad_sum_wallet_dump)
|
||||
self.assert_raises_tool_error('Error: Dumpfile checksum does not match. Computed {}, expected {}{}'.format(checksum, "2" * 10, "0" * 54), '-wallet=badload', '-dumpfile={}'.format(bad_sum_wallet_dump), 'createfromdump')
|
||||
self.assert_raises_tool_error('Error: Checksum is not the correct size', '-wallet=badload', '-dumpfile={}'.format(bad_sum_wallet_dump), 'createfromdump')
|
||||
assert not os.path.isdir(os.path.join(self.nodes[0].datadir, "regtest/wallets", "badload"))
|
||||
dump_data["checksum"] = "3" * 66
|
||||
self.write_dump(dump_data, bad_sum_wallet_dump)
|
||||
self.assert_raises_tool_error('Error: Checksum is not the correct size', '-wallet=badload', '-dumpfile={}'.format(bad_sum_wallet_dump), 'createfromdump')
|
||||
assert not os.path.isdir(os.path.join(self.nodes[0].datadir, "regtest/wallets", "badload"))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user