kdb
[Top] [All Lists]

binary garbage in kdb md output

To: Keith Owens <kaos@xxxxxxx>, kdb@xxxxxxxxxxx
Subject: binary garbage in kdb md output
From: Olaf Hering <olh@xxxxxxx>
Date: Mon, 21 Mar 2005 19:52:33 +0100
Sender: kdb-bounce@xxxxxxxxxxx
User-agent: Mutt und vi sind doch schneller als Notes (und GroupWise)
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@xxxxxxx>

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.
<Prev in Thread] Current Thread [Next in Thread>