parent
6bf5135341
commit
3215c438c8
2 changed files with 174 additions and 1 deletions
159
0020-journal-oops-use-the-length-result-of-sd_journal_get.patch
Normal file
159
0020-journal-oops-use-the-length-result-of-sd_journal_get.patch
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
From 2e74ca0f15d6d25568f5af1cc9cd30b4b01aa849 Mon Sep 17 00:00:00 2001
|
||||
From: Jakub Filak <jfilak@redhat.com>
|
||||
Date: Tue, 14 Oct 2014 03:15:28 +0200
|
||||
Subject: [PATCH 20/21] journal-oops: use the length result of
|
||||
sd_journal_get_data()
|
||||
|
||||
journald doesn't guarantee NULL terminated strings returned from
|
||||
sd_journal_get_data(). It usually works but not always.
|
||||
|
||||
This patch fixes the issue by using the length of field data instead of
|
||||
assuming that string is NULL terminated.
|
||||
|
||||
Resolves: #1141549
|
||||
|
||||
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
||||
---
|
||||
src/plugins/abrt-dump-journal-oops.c | 13 ++++++-----
|
||||
src/plugins/abrt-journal.c | 43 ++++++++++++++++++++++--------------
|
||||
src/plugins/abrt-journal.h | 8 ++++---
|
||||
3 files changed, 40 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/src/plugins/abrt-dump-journal-oops.c b/src/plugins/abrt-dump-journal-oops.c
|
||||
index 3f1f419..0ff9fe0 100644
|
||||
--- a/src/plugins/abrt-dump-journal-oops.c
|
||||
+++ b/src/plugins/abrt-dump-journal-oops.c
|
||||
@@ -38,8 +38,8 @@ static GList* abrt_journal_extract_kernel_oops(abrt_journal_t *journal)
|
||||
|
||||
do
|
||||
{
|
||||
- const char *line = NULL;
|
||||
- if (abrt_journal_get_log_line(journal, &line) < 0)
|
||||
+ char *line = abrt_journal_get_log_line(journal);
|
||||
+ if (line == NULL)
|
||||
error_msg_and_die(_("Cannot read journal data."));
|
||||
|
||||
if (lines_info_count == lines_info_size)
|
||||
@@ -48,10 +48,13 @@ static GList* abrt_journal_extract_kernel_oops(abrt_journal_t *journal)
|
||||
lines_info = xrealloc(lines_info, lines_info_size * sizeof(lines_info[0]));
|
||||
}
|
||||
|
||||
- lines_info[lines_info_count].level = koops_line_skip_level(&line);
|
||||
- koops_line_skip_jiffies(&line);
|
||||
+ char *orig_line = line;
|
||||
+ lines_info[lines_info_count].level = koops_line_skip_level((const char **)&line);
|
||||
+ koops_line_skip_jiffies((const char **)&line);
|
||||
|
||||
- lines_info[lines_info_count].ptr = xstrdup(line);
|
||||
+ memmove(orig_line, line, strlen(line) + 1);
|
||||
+
|
||||
+ lines_info[lines_info_count].ptr = orig_line;
|
||||
|
||||
++lines_info_count;
|
||||
}
|
||||
diff --git a/src/plugins/abrt-journal.c b/src/plugins/abrt-journal.c
|
||||
index 89c8393..e0ae159 100644
|
||||
--- a/src/plugins/abrt-journal.c
|
||||
+++ b/src/plugins/abrt-journal.c
|
||||
@@ -23,6 +23,12 @@
|
||||
|
||||
#include <systemd/sd-journal.h>
|
||||
|
||||
+/*
|
||||
+ * http://www.freedesktop.org/software/systemd/man/sd_journal_get_data.html
|
||||
+ * sd_journal_set_data_threshold() : This threshold defaults to 64K by default.
|
||||
+ */
|
||||
+#define JOURNALD_MAX_FIELD_SIZE (64*1024)
|
||||
+
|
||||
|
||||
struct abrt_journal
|
||||
{
|
||||
@@ -84,33 +90,38 @@ int abrt_journal_get_field(abrt_journal_t *journal, const char *field, const voi
|
||||
return 0;
|
||||
}
|
||||
|
||||
-int abrt_journal_get_string_field(abrt_journal_t *journal, const char *field, const char **value)
|
||||
+char *abrt_journal_get_string_field(abrt_journal_t *journal, const char *field, char *value)
|
||||
{
|
||||
- size_t value_len;
|
||||
- const int r = abrt_journal_get_field(journal, field, (const void **)value, &value_len);
|
||||
+ size_t data_len;
|
||||
+ const char *data;
|
||||
+ const int r = abrt_journal_get_field(journal, field, (const void **)&data, &data_len);
|
||||
if (r < 0)
|
||||
{
|
||||
- return r;
|
||||
+ log_notice("Cannot read journal data");
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
const size_t pfx_len = strlen(field) + 1;
|
||||
- if (value_len < pfx_len)
|
||||
+ if (data_len < pfx_len)
|
||||
{
|
||||
error_msg("Invalid data format from journal: field data are not prefixed with field name");
|
||||
- return -EBADMSG;
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
- *value += pfx_len;
|
||||
- return 0;
|
||||
+ const size_t len = data_len - pfx_len;
|
||||
+ if (value == NULL)
|
||||
+ return xstrndup(data + pfx_len, len);
|
||||
+ /*else*/
|
||||
+
|
||||
+ strncpy(value, data + pfx_len, len);
|
||||
+ /* journal data are not NULL terminated strings, so terminate the string */
|
||||
+ value[len] = '\0';
|
||||
+ return value;
|
||||
}
|
||||
|
||||
-int abrt_journal_get_log_line(abrt_journal_t *journal, const char **line)
|
||||
+char *abrt_journal_get_log_line(abrt_journal_t *journal)
|
||||
{
|
||||
- const int r = abrt_journal_get_string_field(journal, "MESSAGE", line);
|
||||
- if (r < 0)
|
||||
- log_notice("Cannot read journal data. Exiting");
|
||||
-
|
||||
- return r;
|
||||
+ return abrt_journal_get_string_field(journal, "MESSAGE", NULL);
|
||||
}
|
||||
|
||||
int abrt_journal_get_cursor(abrt_journal_t *journal, char **cursor)
|
||||
@@ -272,9 +283,9 @@ void abrt_journal_watch_notify_strings(abrt_journal_watch_t *watch, void *data)
|
||||
{
|
||||
struct abrt_journal_watch_notify_strings *conf = (struct abrt_journal_watch_notify_strings *)data;
|
||||
|
||||
- const char *message = NULL;
|
||||
+ char message[JOURNALD_MAX_FIELD_SIZE + 1];
|
||||
|
||||
- if (abrt_journal_get_string_field(abrt_journal_watch_get_journal(watch), "MESSAGE", &message) < 0)
|
||||
+ if (abrt_journal_get_string_field(abrt_journal_watch_get_journal(watch), "MESSAGE", (char *)message) == NULL)
|
||||
error_msg_and_die("Cannot read journal data.");
|
||||
|
||||
GList *cur = conf->strings;
|
||||
diff --git a/src/plugins/abrt-journal.h b/src/plugins/abrt-journal.h
|
||||
index 219cf60..d509d96 100644
|
||||
--- a/src/plugins/abrt-journal.h
|
||||
+++ b/src/plugins/abrt-journal.h
|
||||
@@ -40,11 +40,13 @@ int abrt_journal_get_field(abrt_journal_t *journal,
|
||||
const void **value,
|
||||
size_t *value_len);
|
||||
|
||||
-int abrt_journal_get_string_field(abrt_journal_t *journal,
|
||||
+/* Returns allocated memory if value is NULL; otherwise makes copy of journald
|
||||
+ * field to memory pointed by value arg. */
|
||||
+char *abrt_journal_get_string_field(abrt_journal_t *journal,
|
||||
const char *field,
|
||||
- const char **value);
|
||||
+ char *value);
|
||||
|
||||
-int abrt_journal_get_log_line(abrt_journal_t *journal, const char **line);
|
||||
+char *abrt_journal_get_log_line(abrt_journal_t *journal);
|
||||
|
||||
int abrt_journal_get_cursor(abrt_journal_t *journal, char **cursor);
|
||||
|
||||
--
|
||||
2.1.0
|
||||
|
||||
16
abrt.spec
16
abrt.spec
|
|
@ -46,7 +46,7 @@
|
|||
Summary: Automatic bug detection and reporting tool
|
||||
Name: abrt
|
||||
Version: 2.3.0
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: GPLv2+
|
||||
Group: Applications/System
|
||||
URL: https://fedorahosted.org/abrt/
|
||||
|
|
@ -67,6 +67,16 @@ Patch0008: 0008-applet-don-t-show-duphash-instead-of-component.patch
|
|||
Patch0010: 0010-console-notifications-skip-non-interactive-shells.patch
|
||||
#Patch0011: 0011-testsuite-run-console-notification-tests-in-screen.patch
|
||||
#Patch0012: 0012-testsuite-add-console-notification-on-the-rhel7-list.patch
|
||||
#Patch0013: 0013-testsuite-install-abrt-console-notification.patch
|
||||
#Patch0014: 0014-testsuite-added-test-for-integration-of-rhtsupport-w.patch
|
||||
#Patch0015: 0015-testsuite-added-another-test-for-integration-of-rhts.patch
|
||||
#Patch0016: 0016-testsuite-added-isolated-test-rhts-test-for-rhel6.patch
|
||||
#Patch0017: 0017-testsuite-console-notifications-fix-couple-of-bugs.patch
|
||||
#Patch0018: 0018-testsuite-dump-journal-oops-check-output.patch
|
||||
#Patch0019: 0019-testsuite-fix-koops-journal-parsing-for-s390x.patch
|
||||
Patch0020: 0020-journal-oops-use-the-length-result-of-sd_journal_get.patch
|
||||
#Patch0021: 0021-testsuite-show-diff-of-dumped-journal-oops-and-expec.patch
|
||||
|
||||
|
||||
# '%%autosetup -S git' -> git
|
||||
BuildRequires: git
|
||||
|
|
@ -977,6 +987,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
|
|||
%config(noreplace) %{_sysconfdir}/profile.d/abrt-console-notification.sh
|
||||
|
||||
%changelog
|
||||
* Tue Oct 14 2014 Jakub Filak <jfilak@redhat.com> - 2.3.0-2
|
||||
- oops: get rid of invalid characters when dumping from journald
|
||||
- Resolves: #1141549, #1149477
|
||||
|
||||
* Mon Oct 13 2014 Jakub Filak <jfilak@redhat.com> - 2.3.0-1
|
||||
- applet: show package instead of duphash
|
||||
- console-notifications: skip non-interactive shells
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue