For bug #153295, make load_infodir ignore files that contain null bytes.
authorZac Medico <zmedico@gentoo.org>
Tue, 31 Oct 2006 23:25:37 +0000 (23:25 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 31 Oct 2006 23:25:37 +0000 (23:25 -0000)
svn path=/main/trunk/; revision=4893

pym/portage.py

index adb97c502ad633758a15419891e21e8ee8e36cd6..400d87b91b62e019ddb48af0cd0a97b4435d8975 100644 (file)
@@ -1497,11 +1497,17 @@ class config:
                                self.configdict["pkg"]["PORT_ENV_FILE"] = infodir+"/environment"
 
                        myre = re.compile('^[A-Z]+$')
+                       null_byte = "\0"
                        for filename in listdir(infodir,filesonly=1,EmptyOnError=1):
                                if myre.match(filename):
                                        try:
-                                               mydata = string.strip(open(infodir+"/"+filename).read())
+                                               file_path = os.path.join(infodir, filename)
+                                               mydata = open(file_path).read().strip()
                                                if len(mydata) < 2048 or filename == "USE":
+                                                       if null_byte in mydata:
+                                                               writemsg("!!! Null byte found in metadata " + \
+                                                                       "file: '%s'\n" % file_path, noiselevel=-1)
+                                                               continue
                                                        if filename == "USE":
                                                                binpkg_flags = "-* " + mydata
                                                                self.configdict["pkg"][filename] = binpkg_flags