Fix unsigned wraparound when creating one time keys

This commit is contained in:
Nicolas Werner 2022-05-21 15:21:14 +02:00
parent 28ff6fa484
commit c792fd28b1
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
1 changed files with 2 additions and 1 deletions

View File

@ -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);