Attached is a patch that allows the ASCII escape character in
printf format strings.

Not allowing the escape character has caused me problems
several times over the years.  Most recently, it messed up the
line-editing functionality in an SSH library which is using
diag_sprintf to format strings to be sent to the SSH client. I
had fixed this in the string-check routine a few times in the
past, but it keeps getting un-fixed when I upgrade eCos. So,
this time I'm submitting a patch. ;)
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/infra/current/ChangeLog,v
retrieving revision 1.60
diff -U10 -r1.60 ChangeLog
--- ChangeLog   6 Jan 2008 11:40:45 -0000       1.60
+++ ChangeLog   10 Jul 2008 15:16:16 -0000
@@ -1,10 +1,15 @@
+2008-07-10  Grant Edwards <[EMAIL PROTECTED]>
+
+        * src/diag.cxx: allow ASCII escape character in printf
+        format strings.
+
 2007-12-28  Oyvind Harboe <[EMAIL PROTECTED]>
        
        * src/memcpy.cxx: added assert when memory areas for memcpy()
        overlaps => result is undefined. It is important to catch *all*
        cases of this if adding an optimisation for unaligned copy.
        
 2007-06-28  Gary Thomas  <[EMAIL PROTECTED]>
 
        * src/tcdiag.cxx: 
        * src/diag.cxx: Add (char *) casts to make GCC 4.2.x happy.
Index: src/diag.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/infra/current/src/diag.cxx,v
retrieving revision 1.22
diff -U10 -r1.22 diag.cxx
--- src/diag.cxx        28 Jun 2007 15:43:07 -0000      1.22
+++ src/diag.cxx        10 Jul 2008 15:16:16 -0000
@@ -236,21 +236,21 @@
         char c = *s;
 
         /* Check for a reasonable length string. */
         
         if( s-str > 2048 ) result = false;
 
         /* We only really support CR, NL, tab and backspace at present.
         * If we want to use other special chars, this test will
          * have to be expanded.  */
 
-        if( c == '\n' || c == '\r' || c == '\b' || c == '\t' )
+        if( c == '\n' || c == '\r' || c == '\b' || c == '\t' || c == '\033' )
             continue;
 
         /* Check for printable chars. This assumes ASCII */
         
         if( c < ' ' || c > '~' )
             result = false;
 
     }
 
     return result;

Reply via email to