Mercurial > hg
diff mcabber/src/jab_iq.c @ 1574:d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
author | franky@veqlargh.fs |
---|---|
date | Tue, 20 Jan 2009 08:48:11 +0100 |
parents | 3df441efb7c2 |
children | 8e52ce94eee0 |
line wrap: on
line diff
--- a/mcabber/src/jab_iq.c Fri Jan 16 22:35:21 2009 +0100 +++ b/mcabber/src/jab_iq.c Tue Jan 20 08:48:11 2009 +0100 @@ -1193,7 +1193,7 @@ xmlnode_put_attrib(y, "type", "text-multi"); xmlnode_put_attrib(y, "var", "status-message"); xmlnode_put_attrib(y, "label", "Message"); - } else if (!strcmp(action, "cancel")) { + } else if (action && !strcmp(action, "cancel")) { xmlnode_put_attrib(command, "status", "canceled"); } else { // (if sessionid and not canceled) y = xmlnode_get_tag(x, "x?xmlns=jabber:x:data"); @@ -1203,16 +1203,18 @@ "value"); message = xmlnode_get_tag_data(xmlnode_get_tag(y, "field?var=status-message"), "value"); - for (s = adhoc_status_list; !s->name || strcmp(s->name, value); s++); - if (s->name) { - char *status = g_strdup_printf("%s %s", s->status, - message ? message : ""); - cmd_setstatus(NULL, status); - g_free(status); - xmlnode_put_attrib(command, "status", "completed"); - xmlnode_put_attrib(iq, "type", "result"); - xmlnode_insert_dataform_result_message(command, - "Status has been changed"); + if (value) { + for (s = adhoc_status_list; s->name && strcmp(s->name, value); s++); + if (s->name) { + char *status = g_strdup_printf("%s %s", s->status, + message ? message : ""); + cmd_setstatus(NULL, status); + g_free(status); + xmlnode_put_attrib(command, "status", "completed"); + xmlnode_put_attrib(iq, "type", "result"); + xmlnode_insert_dataform_result_message(command, + "Status has been changed"); + } } } } @@ -1295,7 +1297,7 @@ xmlnode_insert_tag(field, "required"); foreach_buddy(ROSTER_TYPE_ROOM, &_callback_foreach_buddy_groupchat, &field); - } else if (!strcmp(action, "cancel")) { + } else if (action && !strcmp(action, "cancel")) { xmlnode_put_attrib(command, "status", "canceled"); } else { // (if sessionid and not canceled) xmlnode form = xmlnode_get_tag(x, "x?xmlns=jabber:x:data");