binary garbage in kdb md output

Olaf Hering olh at suse.de
Mon Mar 21 10:52:33 PST 2005


Keith,

what do you see with this testapp? I get an ugly dotted square, which
usually confuses copy&paste into a bugzilla. Also the mirroring between
various bugzilla screws it up even more. All output should be either
plain ASCII or UTF-8. I'm sure kdb should not care about any locale
other than ASCII, so its better to just mask the non-printable bytes.

#include <stdio.h>
int main(void)
{
        unsigned char buf[2];
        buf[0] = 0xc0;
        buf[1] = '\0';
        printf("%s\n", buf);
        return 0;
}




The kernel considers 0xc0-0xff as printable chars, this leads to
binary garbage. Just mask it to ASCII.

Signed-off-by: Olaf Hering <olh at suse.de>

Index: linux-2.6.5/kdb/kdbmain.c
===================================================================
--- linux-2.6.5.orig/kdb/kdbmain.c
+++ linux-2.6.5/kdb/kdbmain.c
@@ -2091,7 +2091,7 @@ kdb_md_line(const char *fmtstr, kdb_mach
 			cp = wc.c;
 #endif
 			wc.word = word;
-#define printable_char(c) ({unsigned char __c = c; isprint(__c) ? __c : '.';})
+#define printable_char(c) ({unsigned char __c = toascii(c); isalnum(__c) ? __c : '.';})
 			switch (bytesperword) {
 			case 8:
 				*c++ = printable_char(*cp++);

---------------------------
Use http://oss.sgi.com/ecartis to modify your settings or to unsubscribe.


More information about the kdb mailing list