aboutsummaryrefslogtreecommitdiff
path: root/lib/e2ee/qolmsession.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-22 14:01:01 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-26 10:46:34 +0200
commitd5c1afc536dde87f460ccadfcfd51444b5e9bb82 (patch)
tree30a85c918c8c37b3ae0904a935f2fc705fe86ed5 /lib/e2ee/qolmsession.cpp
parent2ff045d8b381bfbd64100d083f81b61c5fe87b23 (diff)
downloadlibquotient-d5c1afc536dde87f460ccadfcfd51444b5e9bb82.tar.gz
libquotient-d5c1afc536dde87f460ccadfcfd51444b5e9bb82.zip
Trample Sonar warnings
Diffstat (limited to 'lib/e2ee/qolmsession.cpp')
-rw-r--r--lib/e2ee/qolmsession.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/e2ee/qolmsession.cpp b/lib/e2ee/qolmsession.cpp
index 0d6edd21..e3f69132 100644
--- a/lib/e2ee/qolmsession.cpp
+++ b/lib/e2ee/qolmsession.cpp
@@ -80,10 +80,9 @@ QOlmExpected<QOlmSessionPtr> QOlmSession::createOutboundSession(
const QByteArray& theirOneTimeKey)
{
auto* olmOutboundSession = create();
- const auto randomLength =
- olm_create_outbound_session_random_length(olmOutboundSession);
-
- if (olm_create_outbound_session(
+ if (const auto randomLength =
+ olm_create_outbound_session_random_length(olmOutboundSession);
+ olm_create_outbound_session(
olmOutboundSession, account->data(), theirIdentityKey.data(),
theirIdentityKey.length(), theirOneTimeKey.data(),
theirOneTimeKey.length(), RandomBuffer(randomLength), randomLength)
@@ -136,11 +135,11 @@ QOlmMessage QOlmSession::encrypt(const QByteArray& plaintext)
{
const auto messageMaxLength =
olm_encrypt_message_length(m_session, plaintext.length());
- QByteArray messageBuf(messageMaxLength, '0');
+ QByteArray messageBuf(messageMaxLength, '\0');
// NB: The type has to be calculated before calling olm_encrypt()
const auto messageType = olm_encrypt_message_type(m_session);
- const auto randomLength = olm_encrypt_random_length(m_session);
- if (olm_encrypt(m_session, plaintext.data(), plaintext.length(),
+ if (const auto randomLength = olm_encrypt_random_length(m_session);
+ olm_encrypt(m_session, plaintext.data(), plaintext.length(),
RandomBuffer(randomLength), randomLength, messageBuf.data(),
messageBuf.length())
== olm_error()) {