From 733b98a8ecb5671843cad7bf00cc560192e7c109 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Wed, 8 Mar 2017 05:53:27 +0000 Subject: [PATCH] Guard against null-strings in lines Without that patch, the tool chokes on lines with null-bytes in the middle, which as it turned out sometimes happens in neutron logs. Related-Bug: #1672921 Change-Id: I2ec2c637dc03008f4d964f88a788af0d69abe282 --- oslogmerger/oslogmerger.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oslogmerger/oslogmerger.py b/oslogmerger/oslogmerger.py index 5202a59..e03f132 100644 --- a/oslogmerger/oslogmerger.py +++ b/oslogmerger/oslogmerger.py @@ -90,7 +90,7 @@ class LogEntry(object): return {} def prepare_line(self, line): - return line + return line.replace('\0', ' ') def parse_date(self, line): try: @@ -261,6 +261,7 @@ class MsgLogEntry(LogEntry): # TODO: If year of file creation and file last modification are # different we should start with the cration year and then change to # the next year once the months go back. + line = super(MsgLogEntry, self).prepare_line(line) return '%s%s' % (self.file_year, line) def _calculate_date_length(self):