From 3b020144d5a851492729b59e4e53b0f968f5222b Mon Sep 17 00:00:00 2001 From: DebXWoody Date: Fri, 28 May 2021 21:48:43 +0200 Subject: OMEMO: Don't encrypt to yourself (MUC) As defined in XEP-0384 the application should not encrypt the message to own devices. Within a groupchat, yourself are a recipients as well. We will check the recipients and filter out the own device of the own jid. This Pull Request will fix Issue: #1541 --- src/omemo/omemo.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index b6c7585d..5e945505 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -791,6 +791,19 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_ .device_id = GPOINTER_TO_INT(device_ids_iter->data) }; + // Don't encrypt for this device (according to + // ). + // Yourself as recipients in case of MUC + Jid* me = jid_create(connection_get_fulljid()); + if ( !g_strcmp0(me->barejid, recipients_iter->data) ) { + if (GPOINTER_TO_INT(device_ids_iter->data) == omemo_ctx.device_id) { + jid_destroy(me); + log_debug("[OMEMO][SEND] Skipping %d (my device) ", GPOINTER_TO_INT(device_ids_iter->data)); + continue; + } + } + jid_destroy(me); + log_debug("[OMEMO][SEND] recipients with device id %d for %s", GPOINTER_TO_INT(device_ids_iter->data), recipients_iter->data); res = session_cipher_create(&cipher, omemo_ctx.store, &address, omemo_ctx.signal); if (res != SG_SUCCESS ) { -- cgit 1.4.1-2-gfad0 From 64bcc06259cc74e5a368c09092e3d4ad422bbcd0 Mon Sep 17 00:00:00 2001 From: DebXWoody Date: Sat, 29 May 2021 07:30:36 +0200 Subject: OMEMO: Don't encrypt to yourself (MUC) Use connection_get_barejid instead of connection_get_fulljid. --- src/omemo/omemo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index 5e945505..fa07cfb7 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -794,15 +794,15 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_ // Don't encrypt for this device (according to // ). // Yourself as recipients in case of MUC - Jid* me = jid_create(connection_get_fulljid()); - if ( !g_strcmp0(me->barejid, recipients_iter->data) ) { + char* mybarejid = connection_get_barejid(); + if ( !g_strcmp0(mybarejid, recipients_iter->data) ) { if (GPOINTER_TO_INT(device_ids_iter->data) == omemo_ctx.device_id) { - jid_destroy(me); + free(mybarejid); log_debug("[OMEMO][SEND] Skipping %d (my device) ", GPOINTER_TO_INT(device_ids_iter->data)); continue; } } - jid_destroy(me); + free(mybarejid); log_debug("[OMEMO][SEND] recipients with device id %d for %s", GPOINTER_TO_INT(device_ids_iter->data), recipients_iter->data); res = session_cipher_create(&cipher, omemo_ctx.store, &address, omemo_ctx.signal); -- cgit 1.4.1-2-gfad0