aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-07-05 22:54:28 +0200
committerAndreas Straub <andy@strb.org>2015-07-19 21:32:27 +0200
commit0cf64857cfa8d42b8759ca2934af91d6060c55a5 (patch)
treef5bdb6e8984908bca7f66e0f0cfd4795da1c4212 /src
parent6867b5c3abeeb5116a2542c56a706b733fd9cbf0 (diff)
Only cache session if successfully established
When receiving a message, only remember the XmppAxolotlSession wrapper if the prospective session was actually established. This prevents us from erroneously adding empty sessions that are never established using received PreKeyWhisperMessages, which would lead to errors if we try to use them for sending.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
index d37879c3..faa0e5ad 100644
--- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
@@ -944,12 +944,13 @@ public class AxolotlService {
AxolotlAddress senderAddress = new AxolotlAddress(message.getFrom().toString(),
message.getSenderDeviceId());
+ boolean newSession = false;
XmppAxolotlSession session = sessions.get(senderAddress);
if (session == null) {
Log.d(Config.LOGTAG, "Account: "+account.getJid()+" No axolotl session found while parsing received message " + message);
// TODO: handle this properly
session = new XmppAxolotlSession(axolotlStore, senderAddress);
- sessions.put(senderAddress,session);
+ newSession = true;
}
for (XmppAxolotlMessage.XmppAxolotlMessageHeader header : message.getHeaders()) {
@@ -969,6 +970,10 @@ public class AxolotlService {
}
}
+ if (newSession && plaintextMessage != null) {
+ sessions.put(senderAddress,session);
+ }
+
return plaintextMessage;
}
}