From 5dd1d00a035fb33638827bcd60631a9429022c50 Mon Sep 17 00:00:00 2001 From: derrod Date: Mon, 27 Feb 2023 22:07:48 +0100 Subject: [PATCH] UI: Add mutex to reading public key file --- UI/update/shared-update.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/UI/update/shared-update.cpp b/UI/update/shared-update.cpp index 702a1660f..ad8f778a1 100644 --- a/UI/update/shared-update.cpp +++ b/UI/update/shared-update.cpp @@ -176,12 +176,15 @@ static void LoadPublicKey(std::string &pubkey) static bool CheckDataSignature(const char *name, const std::string &data, const std::string &hexSig) try { + static std::mutex pubkey_mutex; + static std::string obsPubKey; + if (hexSig.empty() || hexSig.length() > 0xFFFF || (hexSig.length() & 1) != 0) throw strprintf("Missing or invalid signature for %s: %s", name, hexSig.c_str()); - static std::string obsPubKey; + std::scoped_lock lock(pubkey_mutex); if (obsPubKey.empty()) LoadPublicKey(obsPubKey);