diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-08-02 10:40:24 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-08-02 10:40:24 +0200 |
commit | ed2fa20414a5071e48e1e0f6238cc4ea3c28f17d (patch) | |
tree | 654c81d52d521a5057f38f9f553ad1010d25ee8d /src/main/java | |
parent | 9dc8e3db9dba2eadcbba5e77d62edf6fa7ff8fe7 (diff) |
handle invalid prekey ids in bundle
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/parser/IqParser.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/IqParser.java b/src/main/java/eu/siacs/conversations/parser/IqParser.java index 4e925e97..a679d00c 100644 --- a/src/main/java/eu/siacs/conversations/parser/IqParser.java +++ b/src/main/java/eu/siacs/conversations/parser/IqParser.java @@ -204,13 +204,15 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived { Log.d(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Encountered unexpected tag in prekeys list: " + preKeyPublicElement); continue; } - Integer preKeyId = Integer.valueOf(preKeyPublicElement.getAttribute("preKeyId")); + Integer preKeyId = null; try { - ECPublicKey preKeyPublic = Curve.decodePoint(Base64.decode(preKeyPublicElement.getContent(), Base64.DEFAULT), 0); + preKeyId = Integer.valueOf(preKeyPublicElement.getAttribute("preKeyId")); + final ECPublicKey preKeyPublic = Curve.decodePoint(Base64.decode(preKeyPublicElement.getContent(), Base64.DEFAULT), 0); preKeyRecords.put(preKeyId, preKeyPublic); + } catch (NumberFormatException e) { + Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"could not parse preKeyId from preKey "+preKeyPublicElement.toString()); } catch (Throwable e) { Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Invalid preKeyPublic (ID="+preKeyId+") in PEP: "+ e.getMessage()+", skipping..."); - continue; } } return preKeyRecords; |