be more careful parsing integers in omemo
This commit is contained in:
parent
5530b0b0e2
commit
0af13fc746
|
@ -91,7 +91,11 @@ public class XmppAxolotlMessage {
|
||||||
private XmppAxolotlMessage(final Element axolotlMessage, final Jid from) throws IllegalArgumentException {
|
private XmppAxolotlMessage(final Element axolotlMessage, final Jid from) throws IllegalArgumentException {
|
||||||
this.from = from;
|
this.from = from;
|
||||||
Element header = axolotlMessage.findChild(HEADER);
|
Element header = axolotlMessage.findChild(HEADER);
|
||||||
this.sourceDeviceId = Integer.parseInt(header.getAttribute(SOURCEID));
|
try {
|
||||||
|
this.sourceDeviceId = Integer.parseInt(header.getAttribute(SOURCEID));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new IllegalArgumentException("invalid source id");
|
||||||
|
}
|
||||||
List<Element> keyElements = header.getChildren();
|
List<Element> keyElements = header.getChildren();
|
||||||
this.keys = new HashMap<>(keyElements.size());
|
this.keys = new HashMap<>(keyElements.size());
|
||||||
for (Element keyElement : keyElements) {
|
for (Element keyElement : keyElements) {
|
||||||
|
@ -102,7 +106,7 @@ public class XmppAxolotlMessage {
|
||||||
byte[] key = Base64.decode(keyElement.getContent().trim(), Base64.DEFAULT);
|
byte[] key = Base64.decode(keyElement.getContent().trim(), Base64.DEFAULT);
|
||||||
this.keys.put(recipientId, key);
|
this.keys.put(recipientId, key);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException("invalid remote id");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IVTAG:
|
case IVTAG:
|
||||||
|
|
|
@ -139,7 +139,11 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||||
if(signedPreKeyPublic == null) {
|
if(signedPreKeyPublic == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Integer.valueOf(signedPreKeyPublic.getAttribute("signedPreKeyId"));
|
try {
|
||||||
|
return Integer.valueOf(signedPreKeyPublic.getAttribute("signedPreKeyId"));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ECPublicKey signedPreKeyPublic(final Element bundle) {
|
public ECPublicKey signedPreKeyPublic(final Element bundle) {
|
||||||
|
@ -255,7 +259,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
|
||||||
Integer signedPreKeyId = signedPreKeyId(bundleElement);
|
Integer signedPreKeyId = signedPreKeyId(bundleElement);
|
||||||
byte[] signedPreKeySignature = signedPreKeySignature(bundleElement);
|
byte[] signedPreKeySignature = signedPreKeySignature(bundleElement);
|
||||||
IdentityKey identityKey = identityKey(bundleElement);
|
IdentityKey identityKey = identityKey(bundleElement);
|
||||||
if(signedPreKeyPublic == null || identityKey == null) {
|
if(signedPreKeyId == null || signedPreKeyPublic == null || identityKey == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue