Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10148 - main/branches/2.1.2/bin
Date: Sun, 04 May 2008 00:51:33
Message-Id: E1JsSRu-0005gr-Md@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-05-04 00:51:29 +0000 (Sun, 04 May 2008)
3 New Revision: 10148
4
5 Modified:
6 main/branches/2.1.2/bin/emerge
7 Log:
8 Validate all the data types inside BlockerCache._load() so that
9 any corruption is detected as soon as possible. (trunk r10147)
10
11
12 Modified: main/branches/2.1.2/bin/emerge
13 ===================================================================
14 --- main/branches/2.1.2/bin/emerge 2008-05-04 00:48:45 UTC (rev 10147)
15 +++ main/branches/2.1.2/bin/emerge 2008-05-04 00:51:29 UTC (rev 10148)
16 @@ -1533,6 +1533,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