For bug #142279, detect and warn about null bytes in CONTENTS. (trunk r5762:5763)
authorZac Medico <zmedico@gentoo.org>
Tue, 23 Jan 2007 21:43:40 +0000 (21:43 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 23 Jan 2007 21:43:40 +0000 (21:43 -0000)
svn path=/main/branches/2.1.2/; revision=5764

pym/portage.py

index 6670665971697344a59373551da59d10d871d9ac..f4d31a1ec91c2cde51e6cb2517c1612b8dab5142 100644 (file)
@@ -6734,8 +6734,16 @@ class dblink:
                myc=open(self.dbdir+"/CONTENTS","r")
                mylines=myc.readlines()
                myc.close()
+               null_byte = "\0"
+               contents_file = os.path.join(self.dbdir, "CONTENTS")
                pos=1
                for line in mylines:
+                       if null_byte in line:
+                               # Null bytes are a common indication of corruption.
+                               writemsg("!!! Null byte found in contents " + \
+                                       "file, line %d: '%s'\n" % (pos, contents_file),
+                                       noiselevel=-1)
+                               continue
                        mydat = line.split()
                        # we do this so we can remove from non-root filesystems
                        # (use the ROOT var to allow maintenance on other partitions)