From 6be5b51a46d1598ac12ddda88b36a2487bf523e0 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Thu, 2 Jul 2020 17:47:07 +0200 Subject: message.c: Log invalid message type So far we logged when we receive a message without a type. Which is actually quite common and makes no sense. --- src/xmpp/message.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 82d8c599..42507b91 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -109,23 +109,11 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con xmpp_free(connection_get_ctx(), text); return 1; } + xmpp_free(connection_get_ctx(), text); // type according to RFC 6121 const char *type = xmpp_stanza_get_type(stanza); - if (type == NULL) { - if (_handle_mam(stanza)) { - xmpp_free(connection_get_ctx(), text); - return 1; - } - - 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); } else if (g_strcmp0(type, STANZA_TYPE_GROUPCHAT) == 0) { @@ -136,6 +124,11 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con } else if (type == NULL || g_strcmp0(type, STANZA_TYPE_CHAT) != 0 || g_strcmp0(type, STANZA_TYPE_NORMAL) != 0 ) { // type: chat, normal (==NULL) + // XEP-0313: Message Archive Management + if (_handle_mam(stanza)) { + return 1; + } + // XEP-0045: Multi-User Chat - invites - presence xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (mucuser) { @@ -172,7 +165,14 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con _handle_chat(stanza, FALSE); } else { - log_info("Received without 'type': %s", text); + // none of the allowed types + char *text; + size_t text_size; + + xmpp_stanza_to_text(stanza, &text, &text_size); + log_info("Received with invalid 'type': %s", text); + + xmpp_free(connection_get_ctx(), text); } return 1; -- cgit 1.4.1-2-gfad0