catch all axolotl parse exception at once. fixes #1692

This commit is contained in:
Daniel Gultsch 2016-02-11 12:26:43 +01:00
parent 1bb38e25f2
commit f37098a54f

View file

@ -6,7 +6,6 @@ import android.util.Log;
import android.util.Pair; import android.util.Pair;
import org.whispersystems.libaxolotl.IdentityKey; import org.whispersystems.libaxolotl.IdentityKey;
import org.whispersystems.libaxolotl.InvalidKeyException;
import org.whispersystems.libaxolotl.ecc.Curve; import org.whispersystems.libaxolotl.ecc.Curve;
import org.whispersystems.libaxolotl.ecc.ECPublicKey; import org.whispersystems.libaxolotl.ecc.ECPublicKey;
import org.whispersystems.libaxolotl.state.PreKeyBundle; import org.whispersystems.libaxolotl.state.PreKeyBundle;
@ -142,7 +141,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
} }
try { try {
publicKey = Curve.decodePoint(Base64.decode(signedPreKeyPublic.getContent(),Base64.DEFAULT), 0); publicKey = Curve.decodePoint(Base64.decode(signedPreKeyPublic.getContent(),Base64.DEFAULT), 0);
} catch (InvalidKeyException | IllegalArgumentException | NullPointerException e) { } catch (Throwable e) {
Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Invalid signedPreKeyPublic in PEP: " + e.getMessage()); Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Invalid signedPreKeyPublic in PEP: " + e.getMessage());
} }
return publicKey; return publicKey;
@ -155,7 +154,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
} }
try { try {
return Base64.decode(signedPreKeySignature.getContent(), Base64.DEFAULT); return Base64.decode(signedPreKeySignature.getContent(), Base64.DEFAULT);
} catch (IllegalArgumentException e) { } catch (Throwable e) {
Log.e(Config.LOGTAG,AxolotlService.LOGPREFIX+" : Invalid base64 in signedPreKeySignature"); Log.e(Config.LOGTAG,AxolotlService.LOGPREFIX+" : Invalid base64 in signedPreKeySignature");
return null; return null;
} }
@ -169,7 +168,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
} }
try { try {
identityKey = new IdentityKey(Base64.decode(identityKeyElement.getContent(), Base64.DEFAULT), 0); identityKey = new IdentityKey(Base64.decode(identityKeyElement.getContent(), Base64.DEFAULT), 0);
} catch (InvalidKeyException | IllegalArgumentException | NullPointerException e) { } catch (Throwable e) {
Log.e(Config.LOGTAG,AxolotlService.LOGPREFIX+" : "+"Invalid identityKey in PEP: "+e.getMessage()); Log.e(Config.LOGTAG,AxolotlService.LOGPREFIX+" : "+"Invalid identityKey in PEP: "+e.getMessage());
} }
return identityKey; return identityKey;
@ -200,7 +199,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
try { try {
ECPublicKey preKeyPublic = Curve.decodePoint(Base64.decode(preKeyPublicElement.getContent(), Base64.DEFAULT), 0); ECPublicKey preKeyPublic = Curve.decodePoint(Base64.decode(preKeyPublicElement.getContent(), Base64.DEFAULT), 0);
preKeyRecords.put(preKeyId, preKeyPublic); preKeyRecords.put(preKeyId, preKeyPublic);
} catch (InvalidKeyException | IllegalArgumentException | NullPointerException e) { } catch (Throwable e) {
Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Invalid preKeyPublic (ID="+preKeyId+") in PEP: "+ e.getMessage()+", skipping..."); Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Invalid preKeyPublic (ID="+preKeyId+") in PEP: "+ e.getMessage()+", skipping...");
continue; continue;
} }