From cc209afc517bdb37f8342457e89c6e2695962ffe Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 10 May 2016 18:11:13 +0200 Subject: stop processing PreKeyWhisperMessage if there is no PreKeyId fixes #1832 --- .../eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java') diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java index b713eb5f..b7d11ec0 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java @@ -168,6 +168,10 @@ public class XmppAxolotlSession { try { try { PreKeyWhisperMessage message = new PreKeyWhisperMessage(encryptedKey); + if (!message.getPreKeyId().isPresent()) { + Log.w(Config.LOGTAG, AxolotlService.getLogprefix(account) + "PreKeyWhisperMessage did not contain a PreKeyId"); + break; + } Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account) + "PreKeyWhisperMessage received, new session ID:" + message.getSignedPreKeyId() + "/" + message.getPreKeyId()); IdentityKey msgIdentityKey = message.getIdentityKey(); if (this.identityKey != null && !this.identityKey.equals(msgIdentityKey)) { @@ -175,9 +179,7 @@ public class XmppAxolotlSession { } else { this.identityKey = msgIdentityKey; plaintext = cipher.decrypt(message); - if (message.getPreKeyId().isPresent()) { - preKeyId = message.getPreKeyId().get(); - } + preKeyId = message.getPreKeyId().get(); } } catch (InvalidMessageException | InvalidVersionException e) { Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account) + "WhisperMessage received"); -- cgit v1.2.3