summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-05-04 00:51:29 +0000
committerZac Medico <zmedico@gentoo.org>2008-05-04 00:51:29 +0000
commit1f8a8caa4aefa2f2ec475e2f5e2f1585419b98b6 (patch)
tree95833da5216c08b74ec8d8e522610dd24c96b062 /bin
parentd61643ad4956196be5222ba45330f9538d8f0ab7 (diff)
downloadportage-1f8a8caa4aefa2f2ec475e2f5e2f1585419b98b6.tar.gz
portage-1f8a8caa4aefa2f2ec475e2f5e2f1585419b98b6.tar.bz2
portage-1f8a8caa4aefa2f2ec475e2f5e2f1585419b98b6.zip
Validate all the data types inside BlockerCache._load() so that
any corruption is detected as soon as possible. (trunk r10147) svn path=/main/branches/2.1.2/; revision=10148
Diffstat (limited to 'bin')
-rwxr-xr-xbin/emerge34
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/emerge b/bin/emerge
index 864ac0be7..960502e9a 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -1533,6 +1533,40 @@ class BlockerCache(DictMixin):
isinstance(self._cache_data, dict) and \
self._cache_data.get("version") == self._cache_version and \
isinstance(self._cache_data.get("blockers"), dict)
+ if cache_valid:
+ # Validate all the atoms and counters so that
+ # corruption is detected as soon as possible.
+ for k, v in self._cache_data["blockers"].iteritems():
+ if not isinstance(k, basestring):
+ cache_valid = False
+ break
+ try:
+ portage.catpkgsplit(k)
+ except portage_exception.InvalidData:
+ cache_valid = False
+ break
+ if not isinstance(v, tuple) or \
+ len(v) != 2:
+ cache_valid = False
+ break
+ counter, atoms = v
+ if not isinstance(counter, (int, long)):
+ cache_valid = False
+ break
+ if not isinstance(atoms, list):
+ cache_valid = False
+ break
+ for atom in atoms:
+ if not isinstance(atom, basestring):
+ cache_valid = False
+ break
+ if atom[:1] != "!" or \
+ not portage.isvalidatom(
+ atom, allow_blockers=True):
+ cache_valid = False
+ break
+ if not cache_valid:
+ break
if not cache_valid:
self._cache_data = {"version":self._cache_version}
self._cache_data["blockers"] = {}