Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3f5a5f2 authored by Kay Sievers's avatar Kay Sievers Committed by Greg Kroah-Hartman
Browse files

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: default avatarMichael Neuling <mikey@neuling.org>
Signed-off-by: default avatarKay Sievers <kay@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5c53d819
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -465,7 +465,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
	for (i = 0; i < msg->text_len; i++) {
	for (i = 0; i < msg->text_len; i++) {
		unsigned char c = log_text(msg)[i];
		unsigned char c = log_text(msg)[i];


		if (c < ' ' || c >= 128)
		if (c < ' ' || c >= 127 || c == '\\')
			len += sprintf(user->buf + len, "\\x%02x", c);
			len += sprintf(user->buf + len, "\\x%02x", c);
		else
		else
			user->buf[len++] = c;
			user->buf[len++] = c;
@@ -489,7 +489,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
				continue;
				continue;
			}
			}


			if (c < ' ' || c >= 128) {
			if (c < ' ' || c >= 127 || c == '\\') {
				len += sprintf(user->buf + len, "\\x%02x", c);
				len += sprintf(user->buf + len, "\\x%02x", c);
				continue;
				continue;
			}
			}