[svn-commits] russell: branch 1.4 r63804 - /branches/1.4/main/manager.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu May 10 15:23:43 MST 2007


Author: russell
Date: Thu May 10 17:23:42 2007
New Revision: 63804

URL: http://svn.digium.com/view/asterisk?view=rev&rev=63804
Log:
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)

Modified:
    branches/1.4/main/manager.c

Modified: branches/1.4/main/manager.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/manager.c?view=diff&rev=63804&r1=63803&r2=63804
==============================================================================
--- branches/1.4/main/manager.c (original)
+++ branches/1.4/main/manager.c Thu May 10 17:23:42 2007
@@ -68,6 +68,7 @@
 #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 @@
 {
 	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 @@
 	/* 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;
 }



More information about the svn-commits mailing list