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.
This commit is contained in:
@@ -99,13 +99,20 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con
|
|||||||
size_t text_size;
|
size_t text_size;
|
||||||
xmpp_stanza_to_text(stanza, &text, &text_size);
|
xmpp_stanza_to_text(stanza, &text, &text_size);
|
||||||
gboolean cont = plugins_on_message_stanza_receive(text);
|
gboolean cont = plugins_on_message_stanza_receive(text);
|
||||||
xmpp_free(connection_get_ctx(), text);
|
|
||||||
if (!cont) {
|
if (!cont) {
|
||||||
|
xmpp_free(connection_get_ctx(), text);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *type = xmpp_stanza_get_type(stanza);
|
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) {
|
if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
|
||||||
_handle_error(stanza);
|
_handle_error(stanza);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user