bintree: validate remove cpv more v2.2.0_alpha105
authorZac Medico <zmedico@gentoo.org>
Mon, 14 May 2012 23:56:20 +0000 (16:56 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 14 May 2012 23:56:20 +0000 (16:56 -0700)
pym/portage/dbapi/bintree.py

index 51c093658fcffc7a84c6c4786c175532148c76b3..a8027ee6c187a91e4ed0009931525feda2853760 100644 (file)
@@ -24,7 +24,7 @@ from portage.cache.mappings import slot_dict_class
 from portage.const import CACHE_PATH
 from portage.dbapi.virtual import fakedbapi
 from portage.dep import Atom, use_reduce, paren_enclose
-from portage.exception import AlarmSignal, InvalidPackageName, \
+from portage.exception import AlarmSignal, InvalidData, InvalidPackageName, \
        PermissionDenied, PortageException
 from portage.localization import _
 from portage import _movefile
@@ -219,6 +219,13 @@ def _pkgindex_cpv_map_latest_build(pkgindex):
        for d in pkgindex.packages:
                cpv = d["CPV"]
 
+               try:
+                       cpv = _pkg_str(cpv)
+               except InvalidData:
+                       writemsg(_("!!! Invalid remote binary package: %s\n") % cpv,
+                               noiselevel=-1)
+                       continue
+
                btime = d.get('BUILD_TIME', '')
                try:
                        btime = int(btime)
@@ -1003,7 +1010,12 @@ class binarytree(object):
                                                noiselevel=-1)
                                        continue
                                mycat = mycat.strip()
-                               fullpkg = mycat+"/"+mypkg[:-5]
+                               try:
+                                       fullpkg = _pkg_str(mycat+"/"+mypkg[:-5])
+                               except InvalidData:
+                                       writemsg(_("!!! Invalid remote binary package: %s\n") % mypkg,
+                                               noiselevel=-1)
+                                       continue
 
                                if fullpkg in metadata:
                                        # When using this old protocol, comparison with the remote