[asterisk-commits] russell: trunk r63805 - in /trunk: ./ main/manager.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu May 10 15:25:55 MST 2007


Author: russell
Date: Thu May 10 17:25:54 2007
New Revision: 63805

URL: http://svn.digium.com/view/asterisk?view=rev&rev=63805
Log:
Merged revisions 63804 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r63804 | russell | 2007-05-10 17:23:42 -0500 (Thu, 10 May 2007) | 4 lines

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:
    trunk/   (props changed)
    trunk/main/manager.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=63805&r1=63804&r2=63805
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Thu May 10 17:25:54 2007
@@ -79,6 +79,7 @@
 #include "asterisk/version.h"
 #include "asterisk/threadstorage.h"
 #include "asterisk/linkedlists.h"
+#include "asterisk/term.h"
 
 /*!
  * Linked list of events.
@@ -1772,7 +1773,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;
@@ -1783,13 +1784,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 asterisk-commits mailing list