From e878b6d266fba2ce8dfabedcbb83163d7ec75178 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Wed, 8 Apr 2020 17:12:16 +0200 Subject: [PATCH] Don't crash if we get a message without from or type MAM messages don't have a type nor a from. If we detect a message without type let's log it and exit without continuing to try to parse it. Otherwise we go into _handle_chat() and crash on the no from. --- src/xmpp/message.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 81928d90..0f5e644d 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -99,13 +99,20 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con size_t text_size; xmpp_stanza_to_text(stanza, &text, &text_size); gboolean cont = plugins_on_message_stanza_receive(text); - xmpp_free(connection_get_ctx(), text); if (!cont) { + xmpp_free(connection_get_ctx(), text); return 1; } const char *type = xmpp_stanza_get_type(stanza); + if (type == NULL) { + log_info("Received without 'type': %s", text); + xmpp_free(connection_get_ctx(), text); + return 1; + } + xmpp_free(connection_get_ctx(), text); + if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { _handle_error(stanza); }