Commit e3f5a5f27153228569f3396049838e9727dae86e

Authored by Kay Sievers
Committed by Greg Kroah-Hartman
1 parent 5c53d819c7

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>

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

... ... @@ -465,7 +465,7 @@
465 465 for (i = 0; i < msg->text_len; i++) {
466 466 unsigned char c = log_text(msg)[i];
467 467  
468   - if (c < ' ' || c >= 128)
  468 + if (c < ' ' || c >= 127 || c == '\\')
469 469 len += sprintf(user->buf + len, "\\x%02x", c);
470 470 else
471 471 user->buf[len++] = c;
... ... @@ -489,7 +489,7 @@
489 489 continue;
490 490 }
491 491  
492   - if (c < ' ' || c >= 128) {
  492 + if (c < ' ' || c >= 127 || c == '\\') {
493 493 len += sprintf(user->buf + len, "\\x%02x", c);
494 494 continue;
495 495 }