1 |
Author: zmedico |
2 |
Date: 2008-05-04 00:48:45 +0000 (Sun, 04 May 2008) |
3 |
New Revision: 10147 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/_emerge/__init__.py |
7 |
Log: |
8 |
Validate all the data types inside BlockerCache._load() so that |
9 |
any corruption is detected as soon as possible. |
10 |
|
11 |
|
12 |
Modified: main/trunk/pym/_emerge/__init__.py |
13 |
=================================================================== |
14 |
--- main/trunk/pym/_emerge/__init__.py 2008-05-03 23:11:54 UTC (rev 10146) |
15 |
+++ main/trunk/pym/_emerge/__init__.py 2008-05-04 00:48:45 UTC (rev 10147) |
16 |
@@ -1392,6 +1392,40 @@ |
17 |
isinstance(self._cache_data, dict) and \ |
18 |
self._cache_data.get("version") == self._cache_version and \ |
19 |
isinstance(self._cache_data.get("blockers"), dict) |
20 |
+ if cache_valid: |
21 |
+ # Validate all the atoms and counters so that |
22 |
+ # corruption is detected as soon as possible. |
23 |
+ for k, v in self._cache_data["blockers"].iteritems(): |
24 |
+ if not isinstance(k, basestring): |
25 |
+ cache_valid = False |
26 |
+ break |
27 |
+ try: |
28 |
+ portage.catpkgsplit(k) |
29 |
+ except portage.exception.InvalidData: |
30 |
+ cache_valid = False |
31 |
+ break |
32 |
+ if not isinstance(v, tuple) or \ |
33 |
+ len(v) != 2: |
34 |
+ cache_valid = False |
35 |
+ break |
36 |
+ counter, atoms = v |
37 |
+ if not isinstance(counter, (int, long)): |
38 |
+ cache_valid = False |
39 |
+ break |
40 |
+ if not isinstance(atoms, list): |
41 |
+ cache_valid = False |
42 |
+ break |
43 |
+ for atom in atoms: |
44 |
+ if not isinstance(atom, basestring): |
45 |
+ cache_valid = False |
46 |
+ break |
47 |
+ if atom[:1] != "!" or \ |
48 |
+ not portage.isvalidatom( |
49 |
+ atom, allow_blockers=True): |
50 |
+ cache_valid = False |
51 |
+ break |
52 |
+ if not cache_valid: |
53 |
+ break |
54 |
if not cache_valid: |
55 |
self._cache_data = {"version":self._cache_version} |
56 |
self._cache_data["blockers"] = {} |
57 |
|
58 |
-- |
59 |
gentoo-commits@l.g.o mailing list |