LinkageMapELF: handle null bytes in NEEDED.ELF.2
authorZac Medico <zmedico@gentoo.org>
Wed, 1 Feb 2012 02:04:11 +0000 (18:04 -0800)
committerZac Medico <zmedico@gentoo.org>
Wed, 1 Feb 2012 02:04:11 +0000 (18:04 -0800)
This avoids an error from os.stat:
  TypeError: must be encoded string without NULL bytes, not str

pym/portage/util/_dyn_libs/LinkageMapELF.py

index f7513573db67b55d18fb26ec4afce969bbbbe244..e71ac735a502793081195399b2061108991060cc 100644 (file)
@@ -287,6 +287,13 @@ class LinkageMapELF(object):
                        l = l.rstrip("\n")
                        if not l:
                                continue
+                       if '\0' in l:
+                               # os.stat() will raise "TypeError: must be encoded string
+                               # without NULL bytes, not str" in this case.
+                               writemsg_level(_("\nLine contains null byte(s) " \
+                                       "in %s: %s\n\n") % (location, l),
+                                       level=logging.ERROR, noiselevel=-1)
+                               continue
                        fields = l.split(";")
                        if len(fields) < 5:
                                writemsg_level(_("\nWrong number of fields " \