[PATCH] Stop printk printing non-printable chars

From: matthew-lkml
Date: Fri Jun 18 2004 - 16:11:36 EST


Hi,

I have had problems recently with the output from dmesg. Somewhere in
the depths of ACPI (drivers/acpi/tables.c:104) the
header->asl_compiler_id contained non-printable characters, and it made
xterm stop displaying any more output. dmesg|less had to be used as less
filters out the duff chars.

The main problem seems to be in ACPI, but I don't see any reason for
printk to even consider printing _any_ non-printable characters at all.
It makes all characters out of the range 32..126 (except for newline)
print as a '?'.

Patch is for 2.6.7.

Matthew


--- linux-2.6.7/kernel/printk.c.orig 2004-06-18 20:44:28.000000000 +0100
+++ linux-2.6.7/kernel/printk.c 2004-06-18 20:53:36.000000000 +0100
@@ -14,6 +14,8 @@
* manfreds@xxxxxxxxxxxxxxxx
* Rewrote bits to get rid of console_lock
* 01Mar01 Andrew Morton <andrewm@xxxxxxxxxx>
+ * Stop emit_log_char from emitting non-ASCII chars.
+ * Matthew Newton, 18 June 2004 <matthew-lkml@xxxxxxxxxxxxxxxxxxxxx>
*/

#include <linux/kernel.h>
@@ -538,7 +540,11 @@
}
log_level_unknown = 0;
}
- emit_log_char(*p);
+ if (p[0] != '\n' && (p[0] < 32 || p[0] > 126)) {
+ emit_log_char('?');
+ } else {
+ emit_log_char(*p);
+ }
if (*p == '\n')
log_level_unknown = 1;
}


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/