diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-05-04 00:48:45 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-05-04 00:48:45 +0000 |
commit | dbcaea5cc70745889d6922209b56b8b861565ecd (patch) | |
tree | 2b2ec980e3a8065535eadc7d72b6d0dad516ff08 | |
parent | 9adcc3284b28b4750e19a8d19b84deb0941b41eb (diff) | |
download | portage-dbcaea5cc70745889d6922209b56b8b861565ecd.tar.gz portage-dbcaea5cc70745889d6922209b56b8b861565ecd.tar.bz2 portage-dbcaea5cc70745889d6922209b56b8b861565ecd.zip |
Validate all the data types inside BlockerCache._load() so that
any corruption is detected as soon as possible.
svn path=/main/trunk/; revision=10147
-rw-r--r-- | pym/_emerge/__init__.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index e7e8e0779..83c9f4da6 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -1392,6 +1392,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"] = {} |