summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-05-21 15:21:14 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-05-21 15:21:14 +0200
commitc792fd28b14ee2bcb1a0a15a8186388b0fae1486 (patch)
treee5288710537b9bd77e7bb8b7dfe9f7e70f0b56ab /src
parentFix bad format string (diff)
downloadnheko-c792fd28b14ee2bcb1a0a15a8186388b0fae1486.tar.xz
Fix unsigned wraparound when creating one time keys
Diffstat (limited to 'src')
-rw-r--r--src/ChatPage.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp

index cd7f3779..d4fbb801 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp
@@ -1025,7 +1025,8 @@ ChatPage::ensureOneTimeKeyCount(const std::map<std::string, uint16_t> &counts, replace_fallback_key); if (count->second < MAX_ONETIME_KEYS || replace_fallback_key) { - const size_t nkeys = MAX_ONETIME_KEYS - count->second; + const size_t nkeys = + count->second < MAX_ONETIME_KEYS ? (MAX_ONETIME_KEYS - count->second) : 0; nhlog::crypto()->info("uploading {} {} keys", nkeys, mtx::crypto::SIGNED_CURVE25519); olm::client()->generate_one_time_keys(nkeys, replace_fallback_key);