From 87cd5dba474f758e291b87a39366bd7edd748bf7 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 17 Nov 2011 18:55:28 -0800 Subject: 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. --- pym/portage/elog/messages.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pym/portage/elog/messages.py b/pym/portage/elog/messages.py index f5232d3e2..98d6206d0 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: -- cgit v1.2.3