[asterisk-commits] anthonyl: branch anthonyl/escape-filter2 r47481 - in /team/anthonyl/escape-fi...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Nov 10 15:30:40 MST 2006


Author: anthonyl
Date: Fri Nov 10 16:30:40 2006
New Revision: 47481

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47481
Log:
changed the code due to more comments and moved the function ot term.c as  term_filter_escapes

Modified:
    team/anthonyl/escape-filter2/include/asterisk/term.h
    team/anthonyl/escape-filter2/include/asterisk/utils.h
    team/anthonyl/escape-filter2/main/logger.c
    team/anthonyl/escape-filter2/main/term.c
    team/anthonyl/escape-filter2/main/utils.c

Modified: team/anthonyl/escape-filter2/include/asterisk/term.h
URL: http://svn.digium.com/view/asterisk/team/anthonyl/escape-filter2/include/asterisk/term.h?view=diff&rev=47481&r1=47480&r2=47481
==============================================================================
--- team/anthonyl/escape-filter2/include/asterisk/term.h (original)
+++ team/anthonyl/escape-filter2/include/asterisk/term.h Fri Nov 10 16:30:40 2006
@@ -59,6 +59,8 @@
 
 char *term_strip(char *outbuf, char *inbuf, int maxout);
 
+void term_filter_escapes(char *line);
+
 char *term_prompt(char *outbuf, const char *inbuf, int maxout);
 
 char *term_prep(void);

Modified: team/anthonyl/escape-filter2/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/team/anthonyl/escape-filter2/include/asterisk/utils.h?view=diff&rev=47481&r1=47480&r2=47481
==============================================================================
--- team/anthonyl/escape-filter2/include/asterisk/utils.h (original)
+++ team/anthonyl/escape-filter2/include/asterisk/utils.h Fri Nov 10 16:30:40 2006
@@ -529,5 +529,4 @@
   to ensure that the DF bit will not be set.
  */
 void ast_enable_packet_fragmentation(int sock);
-char *ast_filter_escapes(const char *line);
 #endif /* _ASTERISK_UTILS_H */

Modified: team/anthonyl/escape-filter2/main/logger.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/escape-filter2/main/logger.c?view=diff&rev=47481&r1=47480&r2=47481
==============================================================================
--- team/anthonyl/escape-filter2/main/logger.c (original)
+++ team/anthonyl/escape-filter2/main/logger.c Fri Nov 10 16:30:40 2006
@@ -848,7 +848,6 @@
 {
 	struct verb *v;
 	struct ast_dynamic_str *buf;
-	char *p;
 	int res;
 	va_list ap;
 	
@@ -876,20 +875,15 @@
 	if (res == AST_DYNSTR_BUILD_FAILED)
 		return;
 
-	p = ast_filter_escapes(buf->str);
-
-	if (!p)
-		return;
+	/* filter out possibly hazardous escape sequences */
+	term_filter_escapes(buf->str);
 	
 	AST_LIST_LOCK(&verbosers);
 	AST_LIST_TRAVERSE(&verbosers, v, list)
-		v->verboser(p);
+		v->verboser(buf->str);
 	AST_LIST_UNLOCK(&verbosers);
 
-  
-	ast_log(LOG_VERBOSE, "%s", p);
-
-	free(p);
+	ast_log(LOG_VERBOSE, "%s", buf->str);
 }
 
 int ast_register_verbose(void (*v)(const char *string)) 

Modified: team/anthonyl/escape-filter2/main/term.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/escape-filter2/main/term.c?view=diff&rev=47481&r1=47480&r2=47481
==============================================================================
--- team/anthonyl/escape-filter2/main/term.c (original)
+++ team/anthonyl/escape-filter2/main/term.c Fri Nov 10 16:30:40 2006
@@ -264,6 +264,37 @@
 	return outbuf;
 }
 
+
+/* filter escape sequences */
+void term_filter_escapes(char *line)
+ {
+	 int i  = 0;
+   
+	 for (i=0;i<strlen(line);i++) {
+		 if (line[i] == ESC) {					 
+			 if ( line[i+1] == '\x5b') {
+				 switch (line[i+2]) {
+				 case '\x30':
+					 break;
+				 case '\x31':
+					 break;
+				 case '\x33':
+					 break;
+				 default:
+					 /* replace ESC with a space */
+					 line[i] = '\x20';
+					 break;
+				 }
+			 } else {
+				 /* replace ESC with a space */
+				 line[i] = '\x20';
+			 }
+		 } 
+	 }
+	 
+	 return;
+ }
+
 char *term_prep(void)
 {
 	return prepdata;

Modified: team/anthonyl/escape-filter2/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/escape-filter2/main/utils.c?view=diff&rev=47481&r1=47480&r2=47481
==============================================================================
--- team/anthonyl/escape-filter2/main/utils.c (original)
+++ team/anthonyl/escape-filter2/main/utils.c Fri Nov 10 16:30:40 2006
@@ -995,46 +995,3 @@
 		ast_log(LOG_WARNING, "Unable to disable PMTU discovery. Large UDP packets may fail to be delivered when sent from this socket.\n");
 #endif /* HAVE_IP_MTU_DISCOVER */
 }
-
-
-/* make output a tad more sane */
-char* ast_filter_escapes(const char *line)
- {
-	 int i  = 0;
-	 int ii = 0;
-	 int tamper = 0;
-	 char *p;
-
-	 
-	 p = ast_calloc(1,strlen(line)+1);
-		
-	 if (!p)
-		 return NULL;
-	 
-	 for (i=0;i<strlen(line);i++) {
-		 if (line[i] == '\x1B') {					 
-			 if ( line[i+1] == '\x5b') {
-				 switch (line[i+2]) {
-				 case '\x30':
-					 break;
-				 case '\x31':
-					 break;
-				 case '\x33':
-					 break;
-				 default:
-					 ast_log(LOG_WARNING, "Someone tried to pass malformed data through your terminal\n"); 
-					 tamper=1;
-					 break;
-				 }
-			 } else
-				 continue;
-
-		 }
-		 if (tamper)
-			 continue;
-		 p[ii] = line[i];
-		 ii++;
-	 }
-
-	 return p;
- }



More information about the asterisk-commits mailing list