[asterisk-commits] jrose: branch 11 r372984 - /branches/11/res/res_xmpp.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Sep 12 13:23:08 CDT 2012
Author: jrose
Date: Wed Sep 12 13:23:04 2012
New Revision: 372984
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=372984
Log:
res_xmpp: Fix a segfault caused by bodyless messages
(closes issue ASTERISK-20361)
Reported by: Noah Engelberth
Review: https://reviewboard.asterisk.org/r/2108/
Modified:
branches/11/res/res_xmpp.c
Modified: branches/11/res/res_xmpp.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/res/res_xmpp.c?view=diff&rev=372984&r1=372983&r2=372984
==============================================================================
--- branches/11/res/res_xmpp.c (original)
+++ branches/11/res/res_xmpp.c Wed Sep 12 13:23:04 2012
@@ -2983,19 +2983,23 @@
static int xmpp_pak_message(struct ast_xmpp_client *client, struct ast_xmpp_client_config *cfg, iks *node, ikspak *pak)
{
struct ast_xmpp_message *message;
+ char *body;
int deleted = 0;
ast_debug(3, "XMPP client '%s' received a message\n", client->name);
+ if (!(body = iks_find_cdata(pak->x, "body"))) {
+ /* Message contains no body, ignore it. */
+ return 0;
+ }
+
if (!(message = ast_calloc(1, sizeof(*message)))) {
return -1;
}
message->arrived = ast_tvnow();
- if (iks_find_cdata(pak->x, "body")) {
- message->message = ast_strdup(iks_find_cdata(pak->x, "body"));
- }
+ message->message = ast_strdup(body);
ast_copy_string(message->id, S_OR(pak->id, ""), sizeof(message->id));
message->from = !ast_strlen_zero(pak->from->full) ? ast_strdup(pak->from->full) : NULL;
More information about the asterisk-commits
mailing list