aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2012-07-06 12:50:09 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-06 12:50:09 -0400
commite3f5a5f27153228569f3396049838e9727dae86e (patch)
tree8ae40775f660a5dcca57960fac222096e1dfefed /kernel
parent5c53d819c71c63fdc91f30a59164583f68e2d63a (diff)
kmsg: escape the backslash character while exporting data
Non-printable characters in the log data are hex-escaped to ensure safe post processing. We need to escape a backslash we find in the data, to be able to distinguish it from a backslash we add for the escaping. Also escape the non-printable character 127. Thanks to Miloslav Trmac for the heads up. Reported-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Kay Sievers <kay@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/printk.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index 12886cd19cd9..505863aa3a7f 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -465,7 +465,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
465 for (i = 0; i < msg->text_len; i++) { 465 for (i = 0; i < msg->text_len; i++) {
466 unsigned char c = log_text(msg)[i]; 466 unsigned char c = log_text(msg)[i];
467 467
468 if (c < ' ' || c >= 128) 468 if (c < ' ' || c >= 127 || c == '\\')
469 len += sprintf(user->buf + len, "\\x%02x", c); 469 len += sprintf(user->buf + len, "\\x%02x", c);
470 else 470 else
471 user->buf[len++] = c; 471 user->buf[len++] = c;
@@ -489,7 +489,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
489 continue; 489 continue;
490 } 490 }
491 491
492 if (c < ' ' || c >= 128) { 492 if (c < ' ' || c >= 127 || c == '\\') {
493 len += sprintf(user->buf + len, "\\x%02x", c); 493 len += sprintf(user->buf + len, "\\x%02x", c);
494 continue; 494 continue;
495 } 495 }