print_string() doesn't escape '\', but uses '\' for escaping
Florian Weimer
Florian.Weimer at RUS.Uni-Stuttgart.DE
Tue Nov 28 17:55:06 CET 2000
The subject says it all. For example, the (Ada) string "\n" and the
string consisting of a newline character (i.e. C "\n") are both
converted to "\n".
In addition, print_sting() uses is_cntrl(), which is locale-dependent
and is probably not what we want. The attached patch corrects this
issues, but assumes that a C char contains ASCII characters.
Of course, the user ID in the output of "--list-keys --with-colons" is
no longer UTF-8, but in fact, it never was because of the quoting of
':'. (I don't think it is desirable to print random 8-bit data from a
non-trustworthy source to the terminal anyway.)
2000-11-28 Florian Weimer <Florian.Weimer at RUS.Uni-Stuttgart.DE>
* miscutil.c (print_string): Don't rely on is_printable() (because
it's locale-dependent), quote REVERSE SOLIDUS as well.
RCS file: /var/cvs/rus-cert/gnupg/util/miscutil.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- util/miscutil.c 2000/11/22 13:19:35 1.1.1.1
+++ util/miscutil.c 2000/11/28 15:55:28 1.2
@@ -172,9 +172,11 @@
print_string( FILE *fp, const byte *p, size_t n, int delim )
{
for( ; n; n--, p++ )
- if( iscntrl( *p ) || *p == delim ) {
+ if( (*p < 32 ) || *p > 126 || *p == '\\' || *p == delim ) {
putc('\\', fp);
- if( *p == '\n' )
+ if (*p == '\\')
+ putc('\\', fp);
+ else if( *p == '\n' )
putc('n', fp);
else if( *p == '\r' )
putc('r', fp);
--
Florian Weimer Florian.Weimer at RUS.Uni-Stuttgart.DE
University of Stuttgart http://cert.uni-stuttgart.de/
RUS-CERT +49-711-685-5973/fax +49-711-685-5898
More information about the Gnupg-devel
mailing list