From 1cfbac4c92cca260f7c272ea9e0c74d6817820a8 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 13 Aug 2022 18:01:16 +0200 Subject: [PATCH] Fix crash when device has no keys to verify --- src/Cache.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Cache.cpp b/src/Cache.cpp index c2c59066..558eb334 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -4381,6 +4381,14 @@ Cache::updateUserKeys(const std::string &sync_token, const mtx::responses::Query nhlog::crypto()->warn("device {}:{} has no signature", user, device_id); continue; } + if (!device_keys.keys.count(device_signing_key) || + !device_keys.keys.count("curve25519:" + device_id)) { + nhlog::crypto()->warn( + "Device key has no curve25519 or ed25519 key {}:{}", + user, + device_id); + continue; + } if (!mtx::crypto::ed25519_verify_signature( device_keys.keys.at(device_signing_key),