diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index d80dd578d..f12466dd0 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -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); 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 crypto::public_key &public_spend_key = *(const crypto::public_key*)&data[4]; - const crypto::public_key &public_view_key = *(const crypto::public_key*)&data[4 + sizeof(crypto::public_key)]; + crypto::public_key public_spend_key, public_view_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; 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); for (size_t n = 0; n < nki; ++n) { - crypto::key_image key_image = *reinterpret_cast(&data[headerlen + n * record_size]); - crypto::signature signature = *reinterpret_cast(&data[headerlen + n * record_size + sizeof(crypto::key_image)]); + crypto::key_image 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)); } @@ -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")); } - const crypto::public_key &public_spend_key = *(const crypto::public_key*)&data[0]; - const crypto::public_key &public_view_key = *(const crypto::public_key*)&data[sizeof(crypto::public_key)]; + crypto::public_key public_spend_key, public_view_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; 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 blobs, bool re const size_t headerlen = 3 * sizeof(crypto::public_key); 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]; - const crypto::public_key &public_view_key = *(const crypto::public_key*)&data[sizeof(crypto::public_key)]; - const crypto::public_key &signer = *(const crypto::public_key*)&data[2*sizeof(crypto::public_key)]; + crypto::public_key public_spend_key, public_view_key, signer; + memcpy(&public_spend_key, &data[0], sizeof(public_spend_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; 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");