From 60720a6d1a4563762335989809b0e09dd7d23086 Mon Sep 17 00:00:00 2001 From: aiwe Date: Wed, 8 May 2024 22:27:33 -0500 Subject: [PATCH] Properly import account keys instead of memcpy because AccountKeys is non-trivially copyable type --- src/gui/MainWindow.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 865c6b2ee..0c7190744 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -22,9 +22,10 @@ #include "MainWindow.h" -#include -#include -#include +#include "Common/Base58.h" +#include "Common/StringTools.h" +#include "Common/Util.h" +#include "CryptoNoteCore/CryptoNoteTools.h" #include "AboutDialog.h" #include "AnimatedLabel.h" #include "AddressBookModel.h" @@ -486,7 +487,9 @@ void MainWindow::importKey() { CryptoNote::AccountKeys keys; if (Tools::Base58::decode_addr(keyString.toStdString(), addressPrefix, data) && addressPrefix == CurrencyAdapter::instance().getAddressPrefix() && data.size() == sizeof(keys)) { - std::memcpy(&keys, data.data(), sizeof(keys)); + if (!fromBinaryArray(keys, Common::asBinaryArray(data))) { + QMessageBox::warning(this, tr("Wallet keys are not valid"), tr("Failed to parse account keys"), QMessageBox::Ok); + } if (WalletAdapter::instance().isOpen()) { WalletAdapter::instance().close(); }