From f24c0d1a1655d152d7a2ac07faa7ecf6119ac7c7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 2 Jul 2014 23:46:12 +0200 Subject: make sure text is escaped --- journal-notify.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/journal-notify.c b/journal-notify.c index 7e78232..d3951ff 100644 --- a/journal-notify.c +++ b/journal-notify.c @@ -37,7 +37,7 @@ int main(int argc, char **argv) { size_t length; char * summary, * message; - const char *summarystr, * messagestr, * icon = DEFAULTICON; + const char * icon = DEFAULTICON; program = argv[0]; @@ -132,24 +132,22 @@ int main(int argc, char **argv) { continue; } - message = strndup(data, length); - messagestr = message + 8; + message = g_markup_escape_text(data + 8, length - 8); /* get SYSLOG_IDENTIFIER field */ if ((rc = sd_journal_get_data(journal, "SYSLOG_IDENTIFIER", &data, &length)) < 0) { fprintf(stderr, "Failed to read syslog identifier field: %s\n", strerror(-rc)); continue; } - summary = strndup(data, length); - summarystr = summary + 18; + summary = g_markup_escape_text(data + 18, length - 18); /* show notification */ if (have_regex > 0) { - if (regexec(®ex, messagestr, 0, NULL, 0) == 0) { - notify(summarystr, messagestr, icon); + if (regexec(®ex, message, 0, NULL, 0) == 0) { + notify(summary, message, icon); } } else { - notify(summarystr, messagestr, icon); + notify(summary, message, icon); } free(summary); -- cgit v1.2.3-70-g09d2