summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico2011-11-18 02:55:28 (GMT)
committerZac Medico2011-11-18 02:55:28 (GMT)
commit87cd5dba474f758e291b87a39366bd7edd748bf7 (patch)
treee09da6999f6d80fd587a235615d3df6a9dba922b
parent3a60d4637ce9c69936f977a79d636c51257cc886 (diff)
collect_ebuild_messages: validate msg type
This will handle invalid message types like the one that triggers the KeyError in dblink._elog_process for bug #390833. It will also output the content of the line in order to help diagnose the source of corruption.
-rw-r--r--pym/portage/elog/messages.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/pym/portage/elog/messages.py b/pym/portage/elog/messages.py
index f5232d3..98d6206 100644
--- a/pym/portage/elog/messages.py
+++ b/pym/portage/elog/messages.py
@@ -18,6 +18,14 @@ from portage import _unicode_decode
import io
import sys
+_log_levels = frozenset([
+ "ERROR",
+ "INFO",
+ "LOG",
+ "QA",
+ "WARN",
+])
+
def collect_ebuild_messages(path):
""" Collect elog messages generated by the bash logging function stored
at 'path'.
@@ -52,9 +60,11 @@ def collect_ebuild_messages(path):
continue
try:
msgtype, msg = l.split(" ", 1)
+ if msgtype not in _log_levels:
+ raise ValueError(msgtype)
except ValueError:
writemsg(_("!!! malformed entry in "
- "log file: '%s'\n") % filename, noiselevel=-1)
+ "log file: '%s': %s\n") % (filename, l), noiselevel=-1)
continue
if lastmsgtype is None: