aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2019-12-22 04:10:53 +0100
committerMarvin W <git@larma.de>2019-12-23 16:58:53 +0100
commita0a956ee0878d24bd06be7f5d75dc4ccd4e7901d (patch)
treecbb079649066c2001b6d6881137108e70eed9d3f /plugins/omemo
parent3218dc0211ac717230fe03fad82681a626d968b5 (diff)
downloaddino-a0a956ee0878d24bd06be7f5d75dc4ccd4e7901d.tar.gz
dino-a0a956ee0878d24bd06be7f5d75dc4ccd4e7901d.zip
Properly check Jids everywhere
Diffstat (limited to 'plugins/omemo')
-rw-r--r--plugins/omemo/src/logic/manager.vala8
-rw-r--r--plugins/omemo/src/logic/trust_manager.vala12
-rw-r--r--plugins/omemo/src/ui/contact_details_dialog.vala6
3 files changed, 21 insertions, 5 deletions
diff --git a/plugins/omemo/src/logic/manager.vala b/plugins/omemo/src/logic/manager.vala
index 2bbd918c..98280a8b 100644
--- a/plugins/omemo/src/logic/manager.vala
+++ b/plugins/omemo/src/logic/manager.vala
@@ -202,8 +202,12 @@ public class Manager : StreamInteractionModule, Object {
//Fetch the bundle for each new device
int inc = 0;
foreach (Row row in db.identity_meta.get_unknown_devices(identity_id, jid.bare_jid.to_string())) {
- module.fetch_bundle(stream, Jid.parse(row[db.identity_meta.address_name]), row[db.identity_meta.device_id], false);
- inc++;
+ try {
+ module.fetch_bundle(stream, new Jid(row[db.identity_meta.address_name]), row[db.identity_meta.device_id], false);
+ inc++;
+ } catch (InvalidJidError e) {
+ warning("Ignoring device with invalid Jid: %s", e.message);
+ }
}
if (inc > 0) {
debug("new bundles %i/%i for %s", inc, device_list.size, jid.to_string());
diff --git a/plugins/omemo/src/logic/trust_manager.vala b/plugins/omemo/src/logic/trust_manager.vala
index 1b8a9436..5a169a82 100644
--- a/plugins/omemo/src/logic/trust_manager.vala
+++ b/plugins/omemo/src/logic/trust_manager.vala
@@ -303,7 +303,11 @@ public class TrustManager {
PreKeySignalMessage msg = Plugin.get_context().deserialize_pre_key_signal_message(Base64.decode((!)key_node_content));
string identity_key = Base64.encode(msg.identity_key.serialize());
foreach (Row row in db.identity_meta.get_with_device_id(identity_id, sid).with(db.identity_meta.identity_key_public_base64, "=", identity_key)) {
- possible_jids.add(new Jid(row[db.identity_meta.address_name]));
+ try {
+ possible_jids.add(new Jid(row[db.identity_meta.address_name]));
+ } catch (InvalidJidError e) {
+ warning("Ignoring invalid jid from database: %s", e.message);
+ }
}
if (possible_jids.size != 1) {
continue;
@@ -311,7 +315,11 @@ public class TrustManager {
} else {
// If we don't know the device name (MUC history w/o MAM), test decryption with all keys with fitting device id
foreach (Row row in db.identity_meta.get_with_device_id(identity_id, sid)) {
- possible_jids.add(new Jid(row[db.identity_meta.address_name]));
+ try {
+ possible_jids.add(new Jid(row[db.identity_meta.address_name]));
+ } catch (InvalidJidError e) {
+ warning("Ignoring invalid jid from database: %s", e.message);
+ }
}
}
}
diff --git a/plugins/omemo/src/ui/contact_details_dialog.vala b/plugins/omemo/src/ui/contact_details_dialog.vala
index 90bd0d3e..ed185685 100644
--- a/plugins/omemo/src/ui/contact_details_dialog.vala
+++ b/plugins/omemo/src/ui/contact_details_dialog.vala
@@ -148,7 +148,11 @@ public class ContactDetailsDialog : Gtk.Dialog {
}
});
foreach (Row device in plugin.db.identity_meta.get_unknown_devices(identity_id, jid.to_string())) {
- module.fetch_bundle(stream, Jid.parse(device[plugin.db.identity_meta.address_name]), device[plugin.db.identity_meta.device_id], false);
+ try {
+ module.fetch_bundle(stream, new Jid(device[plugin.db.identity_meta.address_name]), device[plugin.db.identity_meta.device_id], false);
+ } catch (InvalidJidError e) {
+ warning("Ignoring device with invalid Jid: %s", e.message);
+ }
}
}