about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-05-29 10:29:20 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-05-29 10:29:20 +0200
commite19bf0e30321981ca46ff3370f479679ebc7e240 (patch)
treeca0dce750223c6dc4e32369ddad1d459ec785b67
parent8d9cbef1e3e1e15468f9001a5c7762b110efc9b8 (diff)
parent24e8243a9860c15227c756c5050ea3a5d25d5134 (diff)
downloadprofani-tty-e19bf0e30321981ca46ff3370f479679ebc7e240.tar.gz
Merge branch 'bugfix/1329'
-rw-r--r--src/xmpp/omemo.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/xmpp/omemo.c b/src/xmpp/omemo.c
index 780cfe17..eb4f0fbc 100644
--- a/src/xmpp/omemo.c
+++ b/src/xmpp/omemo.c
@@ -443,25 +443,30 @@ _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata)
 
     xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item");
     if (item) {
-        xmpp_stanza_t *list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
-        if (!list) {
-            return 1;
-        }
-
-        xmpp_stanza_t *device;
-        for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) {
-            if (g_strcmp0(xmpp_stanza_get_name(device), "device") != 0) {
-                continue;
+        if (g_strcmp0(xmpp_stanza_get_id(item), "current") == 0 ) {
+            xmpp_stanza_t *list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
+            if (!list) {
+                return 1;
             }
 
-            const char *id = xmpp_stanza_get_id(device);
-            if (id != NULL) {
-               device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10)));
-            } else {
-               log_error("OMEMO: received device without ID");
+            xmpp_stanza_t *device;
+            for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) {
+                if (g_strcmp0(xmpp_stanza_get_name(device), "device") != 0) {
+                    continue;
+                }
+
+                const char *id = xmpp_stanza_get_id(device);
+                if (id != NULL) {
+                    device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10)));
+                } else {
+                    log_error("OMEMO: received device without ID");
+                }
             }
+        } else {
+            log_warning("OMEMO: User %s has a non 'current' device item list: %s.", from, xmpp_stanza_get_id(item));
         }
     }
+
     omemo_set_device_list(from, device_list);
 
     return 1;