diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-11-17 18:55:28 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-11-17 18:55:28 -0800 |
commit | 87cd5dba474f758e291b87a39366bd7edd748bf7 (patch) | |
tree | e09da6999f6d80fd587a235615d3df6a9dba922b | |
parent | 3a60d4637ce9c69936f977a79d636c51257cc886 (diff) | |
download | portage-87cd5dba474f758e291b87a39366bd7edd748bf7.tar.gz portage-87cd5dba474f758e291b87a39366bd7edd748bf7.tar.bz2 portage-87cd5dba474f758e291b87a39366bd7edd748bf7.zip |
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.py | 12 |
1 files changed, 11 insertions, 1 deletions
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: |