Validate the CATEGORY data in portage.config.load_infodir() and print a warning messa...
authorZac Medico <zmedico@gentoo.org>
Sun, 21 May 2006 04:41:13 +0000 (04:41 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 21 May 2006 04:41:13 +0000 (04:41 -0000)
svn path=/main/trunk/; revision=3382

pym/portage.py

index 2a3ec7baa3248745d8deb5161a14553940646850..7522dc18a571c125dde97388dee0b0e798c7da31 100644 (file)
@@ -1448,9 +1448,17 @@ class config:
                                                                self.configdict["pkg"][filename] = "-* "+mydata
                                                        else:
                                                                self.configdict["pkg"][filename] = mydata
-                                       except SystemExit, e:
-                                               raise
-                                       except:
+                                               # CATEGORY is important because it's used in doebuild
+                                               # to infer the cpv.  If it's corrupted, it leads to
+                                               # strange errors later on, so we'll validate it and
+                                               # print a warning if necessary.
+                                               if filename == "CATEGORY":
+                                                       matchobj = re.match("[-a-zA-Z0-9_.+]+", mydata)
+                                                       if not matchobj or matchobj.start() != 0 or \
+                                                               matchobj.end() != len(mydata):
+                                                               writemsg("!!! CATEGORY file is corrupt: %s\n" % \
+                                                                       os.path.join(infodir, filename))
+                                       except (OSError, IOError):
                                                writemsg("!!! Unable to read file: %s\n" % infodir+"/"+filename)
                                                pass
                        return 1