[oe-commits] [bitbake] 08/19: toaster: orm gen_layerdeps Protect against circular Layer dependencies

git at git.openembedded.org git at git.openembedded.org
Mon Nov 28 14:24:49 UTC 2016


rpurdie pushed a commit to branch master-next
in repository bitbake.

commit e747921c9fe66cfaf77a0063438d4df858498dba
Author: Reyna, David <david.reyna at windriver.com>
AuthorDate: Thu Nov 24 11:19:56 2016 +0000

    toaster: orm gen_layerdeps Protect against circular Layer dependencies
    
    Limit the recursion (to say 20 levels) when processing layer dependencies
    so that circular dependecies do not cause infinite decent and an
    out-of-memory failure. The duplicate found layers are already immediately
    filtered in the code.
    
    [YOCTO #10630]
    
    Signed-off-by: David Reyna <David.Reyna at windriver.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/toaster/orm/models.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py
index 4f8510c..b24e9c5 100644
--- a/lib/toaster/orm/models.py
+++ b/lib/toaster/orm/models.py
@@ -1478,17 +1478,22 @@ class Layer_Version(models.Model):
 
     def get_alldeps(self, project_id):
         """Get full list of unique layer dependencies."""
-        def gen_layerdeps(lver, project):
+        def gen_layerdeps(lver, project, depth):
+            if depth == 0:
+                return
             for ldep in lver.dependencies.all():
                 yield ldep.depends_on
                 # get next level of deps recursively calling gen_layerdeps
-                for subdep in gen_layerdeps(ldep.depends_on, project):
+                for subdep in gen_layerdeps(ldep.depends_on, project, depth-1):
                     yield subdep
 
         project = Project.objects.get(pk=project_id)
         result = []
-        projectlvers = [player.layercommit for player in project.projectlayer_set.all()]
-        for dep in gen_layerdeps(self, project):
+        projectlvers = [player.layercommit for player in
+                        project.projectlayer_set.all()]
+        # protect against infinite layer dependency loops
+        maxdepth = 20
+        for dep in gen_layerdeps(self, project, maxdepth):
             # filter out duplicates and layers already belonging to the project
             if dep not in result + projectlvers:
                 result.append(dep)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list