mirror of
https://github.com/monero-project/monero.git
synced 2026-06-12 19:11:36 -07:00
read import blob crypto fields with memcpy in wallet2
This commit is contained in:
+14
-9
@@ -13227,8 +13227,9 @@ uint64_t wallet2::import_key_images(const std::string &filename, uint64_t &spent
|
|||||||
const size_t headerlen = 4 + 2 * sizeof(crypto::public_key);
|
const size_t headerlen = 4 + 2 * sizeof(crypto::public_key);
|
||||||
THROW_WALLET_EXCEPTION_IF(data.size() < headerlen, error::wallet_internal_error, std::string("Bad data size from file ") + filename);
|
THROW_WALLET_EXCEPTION_IF(data.size() < headerlen, error::wallet_internal_error, std::string("Bad data size from file ") + filename);
|
||||||
const uint32_t offset = (uint8_t)data[0] | (((uint8_t)data[1]) << 8) | (((uint8_t)data[2]) << 16) | (((uint8_t)data[3]) << 24);
|
const uint32_t offset = (uint8_t)data[0] | (((uint8_t)data[1]) << 8) | (((uint8_t)data[2]) << 16) | (((uint8_t)data[3]) << 24);
|
||||||
const crypto::public_key &public_spend_key = *(const crypto::public_key*)&data[4];
|
crypto::public_key public_spend_key, public_view_key;
|
||||||
const crypto::public_key &public_view_key = *(const crypto::public_key*)&data[4 + sizeof(crypto::public_key)];
|
memcpy(&public_spend_key, &data[4], sizeof(public_spend_key));
|
||||||
|
memcpy(&public_view_key, &data[4 + sizeof(crypto::public_key)], sizeof(public_view_key));
|
||||||
const cryptonote::account_public_address &keys = get_account().get_keys().m_account_address;
|
const cryptonote::account_public_address &keys = get_account().get_keys().m_account_address;
|
||||||
if (public_spend_key != keys.m_spend_public_key || public_view_key != keys.m_view_public_key)
|
if (public_spend_key != keys.m_spend_public_key || public_view_key != keys.m_view_public_key)
|
||||||
{
|
{
|
||||||
@@ -13245,8 +13246,10 @@ uint64_t wallet2::import_key_images(const std::string &filename, uint64_t &spent
|
|||||||
ski.reserve(nki);
|
ski.reserve(nki);
|
||||||
for (size_t n = 0; n < nki; ++n)
|
for (size_t n = 0; n < nki; ++n)
|
||||||
{
|
{
|
||||||
crypto::key_image key_image = *reinterpret_cast<const crypto::key_image*>(&data[headerlen + n * record_size]);
|
crypto::key_image key_image;
|
||||||
crypto::signature signature = *reinterpret_cast<const crypto::signature*>(&data[headerlen + n * record_size + sizeof(crypto::key_image)]);
|
crypto::signature signature;
|
||||||
|
memcpy(&key_image, &data[headerlen + n * record_size], sizeof(key_image));
|
||||||
|
memcpy(&signature, &data[headerlen + n * record_size + sizeof(crypto::key_image)], sizeof(signature));
|
||||||
|
|
||||||
ski.push_back(std::make_pair(key_image, signature));
|
ski.push_back(std::make_pair(key_image, signature));
|
||||||
}
|
}
|
||||||
@@ -14313,8 +14316,9 @@ size_t wallet2::import_outputs_from_str(const std::string &outputs_st)
|
|||||||
{
|
{
|
||||||
THROW_WALLET_EXCEPTION(error::wallet_internal_error, std::string("Bad data size for outputs"));
|
THROW_WALLET_EXCEPTION(error::wallet_internal_error, std::string("Bad data size for outputs"));
|
||||||
}
|
}
|
||||||
const crypto::public_key &public_spend_key = *(const crypto::public_key*)&data[0];
|
crypto::public_key public_spend_key, public_view_key;
|
||||||
const crypto::public_key &public_view_key = *(const crypto::public_key*)&data[sizeof(crypto::public_key)];
|
memcpy(&public_spend_key, &data[0], sizeof(public_spend_key));
|
||||||
|
memcpy(&public_view_key, &data[sizeof(crypto::public_key)], sizeof(public_view_key));
|
||||||
const cryptonote::account_public_address &keys = get_account().get_keys().m_account_address;
|
const cryptonote::account_public_address &keys = get_account().get_keys().m_account_address;
|
||||||
if (public_spend_key != keys.m_spend_public_key || public_view_key != keys.m_view_public_key)
|
if (public_spend_key != keys.m_spend_public_key || public_view_key != keys.m_view_public_key)
|
||||||
{
|
{
|
||||||
@@ -14659,9 +14663,10 @@ size_t wallet2::import_multisig(std::vector<cryptonote::blobdata> blobs, bool re
|
|||||||
const size_t headerlen = 3 * sizeof(crypto::public_key);
|
const size_t headerlen = 3 * sizeof(crypto::public_key);
|
||||||
THROW_WALLET_EXCEPTION_IF(data.size() < headerlen, error::wallet_internal_error, "Bad data size");
|
THROW_WALLET_EXCEPTION_IF(data.size() < headerlen, error::wallet_internal_error, "Bad data size");
|
||||||
|
|
||||||
const crypto::public_key &public_spend_key = *(const crypto::public_key*)&data[0];
|
crypto::public_key public_spend_key, public_view_key, signer;
|
||||||
const crypto::public_key &public_view_key = *(const crypto::public_key*)&data[sizeof(crypto::public_key)];
|
memcpy(&public_spend_key, &data[0], sizeof(public_spend_key));
|
||||||
const crypto::public_key &signer = *(const crypto::public_key*)&data[2*sizeof(crypto::public_key)];
|
memcpy(&public_view_key, &data[sizeof(crypto::public_key)], sizeof(public_view_key));
|
||||||
|
memcpy(&signer, &data[2*sizeof(crypto::public_key)], sizeof(signer));
|
||||||
const cryptonote::account_public_address &keys = get_account().get_keys().m_account_address;
|
const cryptonote::account_public_address &keys = get_account().get_keys().m_account_address;
|
||||||
THROW_WALLET_EXCEPTION_IF(public_spend_key != keys.m_spend_public_key || public_view_key != keys.m_view_public_key,
|
THROW_WALLET_EXCEPTION_IF(public_spend_key != keys.m_spend_public_key || public_view_key != keys.m_view_public_key,
|
||||||
error::wallet_internal_error, "Multisig info is for a different account");
|
error::wallet_internal_error, "Multisig info is for a different account");
|
||||||
|
|||||||
Reference in New Issue
Block a user