[Git][NTPsec/ntpsec][master] Deleted 1 commit: Don't crash on bad (MJD,seconds), filter leading trailing NULs.

Gary E. Miller gitlab at mg.gitlab.com
Thu Aug 18 21:15:35 UTC 2016


Gary E. Miller pushed to branch master at NTPsec / ntpsec


WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below.


Deleted commits:
1193dcc2 by Gary E. Miller at 2016-08-18T14:14:26-07:00
Don't crash on bad (MJD,seconds), filter leading trailing NULs.

Linux log files love to gather stray NULs, especially when a daemon
gets killed.

Don't crash on a bad (MJD,seconds) in a log file.  Just set the time
to 0, then the line will get filtered out by the period range.

- - - - -


1 changed file:

- ntpstats/ntpstats.py


Changes:

=====================================
ntpstats/ntpstats.py
=====================================
--- a/ntpstats/ntpstats.py
+++ b/ntpstats/ntpstats.py
@@ -14,7 +14,12 @@ class NTPStats:
     @staticmethod
     def stampfields(line):
         "Extract first two fields, MJD and seconds past midnight."
-        return (int(line.split()[0]), float(line.split()[1]))
+        line = line.strip()
+        try:
+            return (int(line.split()[0]), float(line.split()[1]))
+        except:
+            # unparseable  time 0 and it will be stripped later
+            return (0, 0)
     @staticmethod
     def unixtime(line):
         "Log timestamp (MJD & seconds past midnight) to Unix time"
@@ -42,7 +47,8 @@ class NTPStats:
             except IOError:
                 pass
             # Filter out blank lines (we don't know where these come from)
-            lines = [line for line in lines if line.strip()]
+            lines = [line.strip(' \0\r\n\t')  \
+                     for line in lines if line.strip(' \0\r\n\t')]
             # Sort by date
             lines.sort(key=NTPStats.stampfields)
             # Morph first field into Unix time with fractional seconds 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/1193dcc2ec6c456f42fff6bae910eeba88132a22
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160818/0342e3ab/attachment.html>


More information about the vc mailing list