aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-04-08 17:12:16 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-04-11 16:05:14 +0200
commite878b6d266fba2ce8dfabedcbb83163d7ec75178 (patch)
tree7ea1a63e0ad38461dfc2c6a1611fc680bcf7ee11 /src
parentfe9b520c42ad404dee6137fc5c0937a6bd30bbc4 (diff)
downloadprofani-tty-e878b6d266fba2ce8dfabedcbb83163d7ec75178.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/message.c9
1 files changed, 8 insertions, 1 deletions
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 <message> 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);
}