aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-07-05 22:53:34 +0200
committerAndreas Straub <andy@strb.org>2015-07-19 21:32:27 +0200
commit6867b5c3abeeb5116a2542c56a706b733fd9cbf0 (patch)
tree695411b6c1734aa67778bef4363b3e0e0eb5bad4 /src/main
parent25450bf6d365e4bb71addd38275296575f3a5658 (diff)
Return empty set on invalid PEP devicelist
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java3
-rw-r--r--src/main/java/eu/siacs/conversations/parser/IqParser.java36
2 files changed, 20 insertions, 19 deletions
diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
index cdd8d85d..d37879c3 100644
--- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
@@ -1,5 +1,6 @@
package eu.siacs.conversations.crypto.axolotl;
+import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Base64;
import android.util.Log;
@@ -638,7 +639,7 @@ public class AxolotlService {
return ownDeviceId;
}
- public void registerDevices(final Jid jid, final Set<Integer> deviceIds) {
+ public void registerDevices(final Jid jid, @NonNull final Set<Integer> deviceIds) {
for(Integer i:deviceIds) {
Log.d(Config.LOGTAG, "Adding Device ID:"+ jid + ":"+i);
}
diff --git a/src/main/java/eu/siacs/conversations/parser/IqParser.java b/src/main/java/eu/siacs/conversations/parser/IqParser.java
index 93551787..c147978e 100644
--- a/src/main/java/eu/siacs/conversations/parser/IqParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/IqParser.java
@@ -1,5 +1,6 @@
package eu.siacs.conversations.parser;
+import android.support.annotation.NonNull;
import android.util.Base64;
import android.util.Log;
@@ -96,26 +97,25 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
return items.findChild("item");
}
+ @NonNull
public Set<Integer> deviceIds(final Element item) {
Set<Integer> deviceIds = new HashSet<>();
- if (item == null) {
- return null;
- }
- final Element list = item.findChild("list");
- if(list == null) {
- return null;
- }
- for(Element device : list.getChildren()) {
- if(!device.getName().equals("device")) {
- continue;
- }
- try {
- Integer id = Integer.valueOf(device.getAttribute("id"));
- deviceIds.add(id);
- } catch (NumberFormatException e) {
- Log.e(Config.LOGTAG, "Encountered nvalid <device> node in PEP:" + device.toString()
- + ", skipping...");
- continue;
+ if (item != null) {
+ final Element list = item.findChild("list");
+ if (list != null) {
+ for (Element device : list.getChildren()) {
+ if (!device.getName().equals("device")) {
+ continue;
+ }
+ try {
+ Integer id = Integer.valueOf(device.getAttribute("id"));
+ deviceIds.add(id);
+ } catch (NumberFormatException e) {
+ Log.e(Config.LOGTAG, "Encountered nvalid <device> node in PEP:" + device.toString()
+ + ", skipping...");
+ continue;
+ }
+ }
}
}
return deviceIds;