]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 305888 via svnmerge from
authorRichard Mudgett <rmudgett@digium.com>
Thu, 3 Feb 2011 00:15:07 +0000 (00:15 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Thu, 3 Feb 2011 00:15:07 +0000 (00:15 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r305888 | rmudgett | 2011-02-02 18:02:43 -0600 (Wed, 02 Feb 2011) | 8 lines

  Minor AST_FRAME_TEXT related issues.

  * 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().

  * Fixed AMI SendText action ast_sendtext() return value check.
........

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

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

index f890ae4bfb2702d67db031ddd66b68a70aa2bd48..5a9f66734f37b910b69b659ad49348a9f8c9e316 100644 (file)
@@ -99,10 +99,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);
        return 0;
 }
index fe74a069d533ce501a8dfd7003d7c56afded8322..3666367c70b08a34b4fe91027e03ba51576d1c92 100644 (file)
@@ -14710,7 +14710,7 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req)
                f.subclass = 0;
                f.offset = 0;
                f.data.ptr = 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 */
                return;
index 226ef3fdf96c5482de387295131fbd004d854db1..7718a7ff0a9bd096da65c264c15fb0432732b3e4 100644 (file)
@@ -3470,13 +3470,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;
 }
 
index 4b50d2b1f99d1bfceb93af23e0066bc2cef7734f..560ebbdb58846f1400f21d4d02fc68bff59d7dd3 100644 (file)
@@ -2106,12 +2106,13 @@ static int action_sendtext(struct mansession *s, const struct message *m)
 
        res = ast_sendtext(c, textmsg);
        ast_channel_unlock(c);
-       
-       if (res > 0)
+
+       if (res >= 0) {
                astman_send_ack(s, m, "Success");
-       else
+       } else {
                astman_send_error(s, m, "Failure");
-       
+       }
+
        return res;
 }