aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-10 22:23:42 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-10 22:23:42 +0000
commit7123554eafbc92c9c55c5bbbbfca04490c36353b (patch)
treef62a73a812ce97f10b205b6fc7efd698d37dc43d /main
parent8a667c5594482d21209b4762f5343d1b92266037 (diff)
Strip terminal escape sequences from CLI command output that is going to be
sent out over the manager interface. (issue #9659, reported by pari, fixed by me) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@63804 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/manager.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/main/manager.c b/main/manager.c
index 32a8133a6..383411fbe 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -68,6 +68,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/http.h"
#include "asterisk/threadstorage.h"
#include "asterisk/linkedlists.h"
+#include "asterisk/term.h"
struct fast_originate_helper {
char tech[AST_MAX_EXTENSION];
@@ -1612,7 +1613,7 @@ static int action_command(struct mansession *s, const struct message *m)
{
const char *cmd = astman_get_header(m, "Command");
const char *id = astman_get_header(m, "ActionID");
- char *buf;
+ char *buf, *final_buf;
char template[] = "/tmp/ast-ami-XXXXXX"; /* template for temporary file */
int fd = mkstemp(template);
off_t l;
@@ -1623,13 +1624,16 @@ static int action_command(struct mansession *s, const struct message *m)
/* FIXME: Wedge a ActionID response in here, waiting for later changes */
ast_cli_command(fd, cmd); /* XXX need to change this to use a FILE * */
l = lseek(fd, 0, SEEK_END); /* how many chars available */
- buf = alloca(l+1);
+ buf = alloca(l + 1);
+ final_buf = alloca(l + 1);
lseek(fd, 0, SEEK_SET);
read(fd, buf, l);
buf[l] = '\0';
close(fd);
unlink(template);
- astman_append(s, buf);
+ term_strip(final_buf, buf, l);
+ final_buf[l] = '\0';
+ astman_append(s, final_buf);
astman_append(s, "--END COMMAND--\r\n\r\n");
return 0;
}