Browse Source

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
Ihar Hrachyshka 2 years ago
parent
commit
733b98a8ec
1 changed files with 2 additions and 1 deletions
  1. 2
    1
      oslogmerger/oslogmerger.py

+ 2
- 1
oslogmerger/oslogmerger.py View File

@@ -90,7 +90,7 @@ class LogEntry(object):
90 90
         return {}
91 91
 
92 92
     def prepare_line(self, line):
93
-        return line
93
+        return line.replace('\0', ' ')
94 94
 
95 95
     def parse_date(self, line):
96 96
         try:
@@ -261,6 +261,7 @@ class MsgLogEntry(LogEntry):
261 261
         # TODO: If year of file creation and file last modification are
262 262
         # different we should start with the cration year and then change to
263 263
         # the next year once the months go back.
264
+        line = super(MsgLogEntry, self).prepare_line(line)
264 265
         return '%s%s' % (self.file_year, line)
265 266
 
266 267
     def _calculate_date_length(self):

Loading…
Cancel
Save