]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Minor AST_FRAME_TEXT related issues.
authorRichard Mudgett <rmudgett@digium.com>
Thu, 3 Feb 2011 00:02:43 +0000 (00:02 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Thu, 3 Feb 2011 00:02:43 +0000 (00:02 +0000)
* Include the null terminator in the buffer length.  When the frame is
queued it is copied.  If the null terminator is not part of the frame
buffer length, the receiver could see garbage appended onto it.

* Add channel lock protection with ast_sendtext().

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@305888 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_sendtext.c
channels/chan_sip.c
main/channel.c

index e64bf03ee56832a131b9bc69641eb00a61b83a11..297630e3e8b97a48035e33388f897656c337f84f 100644 (file)
@@ -105,10 +105,10 @@ static int sendtext_exec(struct ast_channel *chan, void *data)
                return 0;
        }
        status = "FAILURE";
-       ast_channel_unlock(chan);
        res = ast_sendtext(chan, args.text);
        if (!res)
                status = "SUCCESS";
+       ast_channel_unlock(chan);
        pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
        ast_module_user_remove(u);
        return 0;
index a38297ca2962e58535144d851e47a954015240ad..87d6f34dfea601a4a2594b0d44db82c30edc7658 100644 (file)
@@ -11044,7 +11044,7 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req)
                f.subclass = 0;
                f.offset = 0;
                f.data = buf;
-               f.datalen = strlen(buf);
+               f.datalen = strlen(buf) + 1;
                ast_queue_frame(p->owner, &f);
                transmit_response(p, "202 Accepted", req); /* We respond 202 accepted, since we relay the message */
        } else { /* Message outside of a call, we do not support that */
index 8ac513d4654b61b5b4a96140b7403b473c053634..41753fb8fbdb310eedbb0a82b22c41c1178494f2 100644 (file)
@@ -2905,13 +2905,18 @@ char *ast_recvtext(struct ast_channel *chan, int timeout)
 int ast_sendtext(struct ast_channel *chan, const char *text)
 {
        int res = 0;
+
+       ast_channel_lock(chan);
        /* Stop if we're a zombie or need a soft hangup */
-       if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan))
+       if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
+               ast_channel_unlock(chan);
                return -1;
+       }
        CHECK_BLOCKING(chan);
        if (chan->tech->send_text)
                res = chan->tech->send_text(chan, text);
        ast_clear_flag(chan, AST_FLAG_BLOCKING);
+       ast_channel_unlock(chan);
        return res;
 }