stop processing PreKeyWhisperMessage if there is no PreKeyId

fixes #1832
This commit is contained in:
Daniel Gultsch 2016-05-10 18:11:13 +02:00
parent 8e3948e495
commit cc209afc51
1 changed files with 5 additions and 3 deletions

View File

@ -168,6 +168,10 @@ public class XmppAxolotlSession {
try { try {
try { try {
PreKeyWhisperMessage message = new PreKeyWhisperMessage(encryptedKey); 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()); Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account) + "PreKeyWhisperMessage received, new session ID:" + message.getSignedPreKeyId() + "/" + message.getPreKeyId());
IdentityKey msgIdentityKey = message.getIdentityKey(); IdentityKey msgIdentityKey = message.getIdentityKey();
if (this.identityKey != null && !this.identityKey.equals(msgIdentityKey)) { if (this.identityKey != null && !this.identityKey.equals(msgIdentityKey)) {
@ -175,10 +179,8 @@ public class XmppAxolotlSession {
} else { } else {
this.identityKey = msgIdentityKey; this.identityKey = msgIdentityKey;
plaintext = cipher.decrypt(message); plaintext = cipher.decrypt(message);
if (message.getPreKeyId().isPresent()) {
preKeyId = message.getPreKeyId().get(); preKeyId = message.getPreKeyId().get();
} }
}
} catch (InvalidMessageException | InvalidVersionException e) { } catch (InvalidMessageException | InvalidVersionException e) {
Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account) + "WhisperMessage received"); Log.i(Config.LOGTAG, AxolotlService.getLogprefix(account) + "WhisperMessage received");
WhisperMessage message = new WhisperMessage(encryptedKey); WhisperMessage message = new WhisperMessage(encryptedKey);