1 |
Author: zmedico |
2 |
Date: 2010-03-02 19:50:25 +0000 (Tue, 02 Mar 2010) |
3 |
New Revision: 15534 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.7/pym/portage/cache/flat_hash.py |
7 |
Log: |
8 |
Bug #302764 - Inside __iter__, only recurse 1 deep, in order to avoid |
9 |
iteration over entries from another nested cache instance. This can |
10 |
happen if the user nests an overlay inside /usr/portage/local. Thanks |
11 |
to Vlastimil Babka <caster@g.o> for this patch. (trunk r15295) |
12 |
|
13 |
Modified: main/branches/2.1.7/pym/portage/cache/flat_hash.py |
14 |
=================================================================== |
15 |
--- main/branches/2.1.7/pym/portage/cache/flat_hash.py 2010-03-02 19:50:13 UTC (rev 15533) |
16 |
+++ main/branches/2.1.7/pym/portage/cache/flat_hash.py 2010-03-02 19:50:25 UTC (rev 15534) |
17 |
@@ -120,11 +120,12 @@ |
18 |
|
19 |
def __iter__(self): |
20 |
"""generator for walking the dir struct""" |
21 |
- dirs = [self.location] |
22 |
+ dirs = [(0, self.location)] |
23 |
len_base = len(self.location) |
24 |
while len(dirs): |
25 |
try: |
26 |
- dir_list = os.listdir(dirs[0]) |
27 |
+ depth = dirs[0][0] |
28 |
+ dir_list = os.listdir(dirs[0][1]) |
29 |
except OSError as e: |
30 |
if e.errno != errno.ENOENT: |
31 |
raise |
32 |
@@ -134,10 +135,15 @@ |
33 |
for l in dir_list: |
34 |
if l.endswith(".cpickle"): |
35 |
continue |
36 |
- p = os.path.join(dirs[0],l) |
37 |
+ p = os.path.join(dirs[0][1], l) |
38 |
st = os.lstat(p) |
39 |
if stat.S_ISDIR(st.st_mode): |
40 |
- dirs.append(p) |
41 |
+ # Only recurse 1 deep, in order to avoid iteration over |
42 |
+ # entries from another nested cache instance. This can |
43 |
+ # happen if the user nests an overlay inside |
44 |
+ # /usr/portage/local as in bug #302764. |
45 |
+ if depth < 1: |
46 |
+ dirs.append((depth+1, p)) |
47 |
continue |
48 |
yield p[len_base+1:] |
49 |
dirs.pop(0) |