summaryrefslogtreecommitdiffstats
path: root/pym/portage.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-04-09 05:31:53 +0000
committerZac Medico <zmedico@gentoo.org>2008-04-09 05:31:53 +0000
commit4f6b4ce641ee2e33b11c23d1c955c18e906a8a72 (patch)
treeb0ee7b0d9ab1dfeb7e38bc3629f1bb633c8a7fdb /pym/portage.py
parentc4b00468909daab5b1ff48178cfaef6b60a66f02 (diff)
downloadportage-4f6b4ce641ee2e33b11c23d1c955c18e906a8a72.tar.gz
portage-4f6b4ce641ee2e33b11c23d1c955c18e906a8a72.tar.bz2
portage-4f6b4ce641ee2e33b11c23d1c955c18e906a8a72.zip
Handle issues with newlines in elog messages that can trigger an unhandled
ValueError to be raised from a split() call inside collect_ebuild_messages(): * Use \0 to delimit messages, so that that elog messages containing newlines are handled correctly. * Handle a potential ValueError when splitting the message type. (trunk r9763) svn path=/main/branches/2.1.2/; revision=9764
Diffstat (limited to 'pym/portage.py')
-rw-r--r--pym/portage.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/pym/portage.py b/pym/portage.py
index ca3445548..8680c34df 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -535,16 +535,24 @@ def elog_process(cpv, mysettings):
mylogfiles.reverse()
all_logentries = {}
for msgfunction in mylogfiles:
+ filename = os.path.join(path, msgfunction)
if msgfunction not in portage_const.EBUILD_PHASES:
- writemsg("!!! can't process invalid log file: %s\n" % f,
+ writemsg("!!! can't process invalid log file: '%s'\n" % filename,
noiselevel=-1)
continue
if not msgfunction in all_logentries:
all_logentries[msgfunction] = []
lastmsgtype = None
msgcontent = []
- for l in open(os.path.join(path, msgfunction), "r").readlines():
- msgtype, msg = l.split(" ", 1)
+ for l in open(filename, "r").read().split("\0"):
+ if not l:
+ continue
+ try:
+ msgtype, msg = l.split(" ", 1)
+ except ValueError:
+ writemsg("!!! malformed entry in " + \
+ "log file: '%s'\n" % filename, noiselevel=-1)
+ continue
if lastmsgtype is None:
lastmsgtype = msgtype
if msgtype == lastmsgtype: