summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-09 16:49:28 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-09 16:49:28 +0200
commit5b4c61cd0b7d35f5a905c83a0ee111a1876a7873 (patch)
tree08fa0dda6f66bd02adc4f2c2f9bdc7f6c7cfaab6 /src/journal
parente7573d7fa9366f72fb81e0a02d82dbb0dfd106aa (diff)
journald: properly unescape messages from /dev/kmsg
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journald.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/journal/journald.c b/src/journal/journald.c
index d0c96186fa..765c0e3428 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -1815,6 +1815,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) {
usec_t usec;
char *identifier = NULL, *pid = NULL, *e, *f, *k;
uint64_t serial;
+ size_t pl;
assert(s);
assert(p);
@@ -1867,6 +1868,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) {
return;
*e = 0;
+ pl = e - p;
l -= (e - p) + 1;
k = e + 1;
@@ -1885,16 +1887,12 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) {
*e = 0;
- m = new(char, sizeof("_KERNEL_") - 1 + e - k);
+ m = cunescape_length_with_prefix(k, e - k, "_KERNEL_");
if (!m)
break;
- memcpy(m, "_KERNEL_", sizeof("_KERNEL_") - 1);
- memcpy(m + sizeof("_KERNEL_") - 1, k, e - k);
-
- iovec[n].iov_base = m;
- iovec[n].iov_len = sizeof("_KERNEL_") - 1 + e - k;
- n++, z++;
+ IOVEC_SET_STRING(iovec[n++], m);
+ z++;
l -= (e - k) + 1;
k = e + 1;
@@ -1935,7 +1933,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) {
IOVEC_SET_STRING(iovec[n++], syslog_facility);
}
- message = strappend("MESSAGE=", p);
+ message = cunescape_length_with_prefix(p, pl, "MESSAGE=");
if (message)
IOVEC_SET_STRING(iovec[n++], message);