catch a few NPE when parsing invalid pep nodes

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/parser/IqParser.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/parser/IqParser.java 🔗

@@ -142,7 +142,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
 		}
 		try {
 			publicKey = Curve.decodePoint(Base64.decode(signedPreKeyPublic.getContent(),Base64.DEFAULT), 0);
-		} catch (InvalidKeyException | IllegalArgumentException e) {
+		} catch (InvalidKeyException | IllegalArgumentException | NullPointerException e) {
 			Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Invalid signedPreKeyPublic in PEP: " + e.getMessage());
 		}
 		return publicKey;
@@ -169,7 +169,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
 		}
 		try {
 			identityKey = new IdentityKey(Base64.decode(identityKeyElement.getContent(), Base64.DEFAULT), 0);
-		} catch (InvalidKeyException | IllegalArgumentException e) {
+		} catch (InvalidKeyException | IllegalArgumentException | NullPointerException e) {
 			Log.e(Config.LOGTAG,AxolotlService.LOGPREFIX+" : "+"Invalid identityKey in PEP: "+e.getMessage());
 		}
 		return identityKey;
@@ -200,7 +200,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
 			try {
 				ECPublicKey preKeyPublic = Curve.decodePoint(Base64.decode(preKeyPublicElement.getContent(), Base64.DEFAULT), 0);
 				preKeyRecords.put(preKeyId, preKeyPublic);
-			} catch (InvalidKeyException | IllegalArgumentException e) {
+			} catch (InvalidKeyException | IllegalArgumentException | NullPointerException e) {
 				Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Invalid preKeyPublic (ID="+preKeyId+") in PEP: "+ e.getMessage()+", skipping...");
 				continue;
 			}