mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Fixed possible segfault when no type attribute on incoming messages
This commit is contained in:
parent
3f8813bb1b
commit
a314e03db2
34
src/jabber.c
34
src/jabber.c
@ -255,30 +255,32 @@ static int
|
|||||||
_message_handler(xmpp_conn_t * const conn,
|
_message_handler(xmpp_conn_t * const conn,
|
||||||
xmpp_stanza_t * const stanza, void * const userdata)
|
xmpp_stanza_t * const stanza, void * const userdata)
|
||||||
{
|
{
|
||||||
char *type;
|
char *type = NULL;
|
||||||
char *from;
|
char *from = NULL;
|
||||||
|
|
||||||
type = xmpp_stanza_get_attribute(stanza, "type");
|
type = xmpp_stanza_get_attribute(stanza, "type");
|
||||||
from = xmpp_stanza_get_attribute(stanza, "from");
|
from = xmpp_stanza_get_attribute(stanza, "from");
|
||||||
|
|
||||||
if (strcmp(type, "error") == 0) {
|
if (type != NULL) {
|
||||||
char *err_msg = NULL;
|
if (strcmp(type, "error") == 0) {
|
||||||
xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, "error");
|
char *err_msg = NULL;
|
||||||
if (error == NULL) {
|
xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, "error");
|
||||||
log_debug("error message without <error/> received");
|
if (error == NULL) {
|
||||||
return 1;
|
log_debug("error message without <error/> received");
|
||||||
} else {
|
|
||||||
xmpp_stanza_t *err_cond = xmpp_stanza_get_children(error);
|
|
||||||
if (err_cond == NULL) {
|
|
||||||
log_debug("error message without <defined-condition/> received");
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
err_msg = xmpp_stanza_get_name(err_cond);
|
xmpp_stanza_t *err_cond = xmpp_stanza_get_children(error);
|
||||||
|
if (err_cond == NULL) {
|
||||||
|
log_debug("error message without <defined-condition/> received");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
err_msg = xmpp_stanza_get_name(err_cond);
|
||||||
|
}
|
||||||
|
// TODO: process 'type' attribute from <error/> [RFC6120, 8.3.2]
|
||||||
}
|
}
|
||||||
// TODO: process 'type' attribute from <error/> [RFC6120, 8.3.2]
|
prof_handle_error_message(from, err_msg);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
prof_handle_error_message(from, err_msg);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body");
|
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body");
|
||||||
|
Loading…
Reference in New Issue
Block a user