aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2011-02-03 00:15:07 +0000
committerrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2011-02-03 00:15:07 +0000
commitc9d7b8a0518cafcd949528ac9d378e761918c55d (patch)
tree1abdbb1c0c54a90351d3ea3fd6e072a03e02dcbf /main
parent70fd3ba0a975322413cd73f477cccc497187beb7 (diff)
Merged revisions 305888 via svnmerge from
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: http://svn.digium.com/svn/asterisk/branches/1.6.2@305889 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/channel.c7
-rw-r--r--main/manager.c9
2 files changed, 11 insertions, 5 deletions
diff --git a/main/channel.c b/main/channel.c
index 226ef3fdf..7718a7ff0 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -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;
}
diff --git a/main/manager.c b/main/manager.c
index 4b50d2b1f..560ebbdb5 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -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;
}