From b1bd1ecca8d7cad4423cebead6f2d1f57b6adb33 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Thu, 25 Mar 2021 15:26:16 +0100 Subject: message: make _message_handler safer --- src/xmpp/message.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/xmpp/message.c b/src/xmpp/message.c index f3e81794..1f43389e 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -226,13 +226,15 @@ _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* con char* mybarejid = connection_get_barejid(); const char* const stanza_from = xmpp_stanza_get_from(stanza); - if (g_strcmp0(mybarejid, stanza_from) != 0) { - log_warning("Invalid carbon received, from: %s", stanza_from); - msg_stanza = NULL; - } else { - is_carbon = TRUE; - // returns NULL if it was a carbon that was invalid, so that we dont parse later - msg_stanza = _handle_carbons(carbons); + if (stanza_from) { + if (g_strcmp0(mybarejid, stanza_from) != 0) { + log_warning("Invalid carbon received, from: %s", stanza_from); + msg_stanza = NULL; + } else { + is_carbon = TRUE; + // returns NULL if it was a carbon that was invalid, so that we dont parse later + msg_stanza = _handle_carbons(carbons); + } } free(mybarejid); -- cgit 1.4.1-2-gfad0