summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2012-09-12 18:33:47 +0000
committerJonathan Rose <jrose@digium.com>2012-09-12 18:33:47 +0000
commit1e59e7ee08db3113c10e4736ada217f3091e37b7 (patch)
treea66e2f42868d2475bb8db3374e80679ecd3bc5bd /res
parent1a79c9c18234fd8329e2315dec862cf7c32db8b3 (diff)
res_xmpp: Fix a segfault caused by bodyless messages
(closes issue ASTERISK-20361) Reported by: Noah Engelberth Review: https://reviewboard.asterisk.org/r/2108/ ........ Merged revisions 372984 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@372985 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r--res/res_xmpp.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/res/res_xmpp.c b/res/res_xmpp.c
index 575f1426d..ce5c9ea53 100644
--- a/res/res_xmpp.c
+++ b/res/res_xmpp.c
@@ -2983,19 +2983,23 @@ static int xmpp_component_authenticating(struct ast_xmpp_client *client, struct
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;