From c07341830670819b4dc4a16c56fcac9ad21be16d Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 23 Jan 2017 20:56:05 +0000 Subject: [PATCH 1/2] Check roster contact before displayng typing notification fixes #896 --- src/ui/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ui/core.c b/src/ui/core.c index f16080a2..a12bb3ea 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -298,8 +298,12 @@ ui_contact_typing(const char *const barejid, const char *const resource) if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_TYPING_CURRENT)) ) { PContact contact = roster_get_contact(barejid); char const *display_usr = NULL; - if (p_contact_name(contact)) { - display_usr = p_contact_name(contact); + if (contact) { + if (p_contact_name(contact)) { + display_usr = p_contact_name(contact); + } else { + display_usr = barejid; + } } else { display_usr = barejid; } From 8e75437a7e43d4c55e861691f74892e666e29b0b Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 23 Jan 2017 22:25:36 +0000 Subject: [PATCH 2/2] Add carbons from check --- src/xmpp/message.c | 9 ++++++++- tests/functionaltests/test_carbons.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 9d80fb1f..3f8ad5a0 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -714,6 +714,14 @@ _handle_carbons(xmpp_stanza_t *const stanza) return TRUE; } + Jid *my_jid = jid_create(connection_get_fulljid()); + const char *const stanza_from = xmpp_stanza_get_from(stanza); + Jid *msg_jid = jid_create(stanza_from); + if (g_strcmp0(my_jid->barejid, msg_jid->barejid) != 0) { + log_warning("Invalid carbon received, from: %s", stanza_from); + return TRUE; + } + const gchar *to = xmpp_stanza_get_to(message); const gchar *from = xmpp_stanza_get_from(message); @@ -722,7 +730,6 @@ _handle_carbons(xmpp_stanza_t *const stanza) Jid *jid_from = jid_create(from); Jid *jid_to = jid_create(to); - Jid *my_jid = jid_create(connection_get_fulljid()); // check for pgp encrypted message char *enc_message = NULL; diff --git a/tests/functionaltests/test_carbons.c b/tests/functionaltests/test_carbons.c index 414284ff..7926a76f 100644 --- a/tests/functionaltests/test_carbons.c +++ b/tests/functionaltests/test_carbons.c @@ -70,7 +70,7 @@ receive_carbon(void **state) assert_true(prof_output_exact("unencrypted")); stbbr_send( - "" + "" "" "" ""