depmod.pl: add recursive sanity check
authorMike Frysinger <vapier@gentoo.org>
Tue, 16 Nov 2010 12:15:00 +0000 (07:15 -0500)
committerMike Frysinger <vapier@gentoo.org>
Tue, 16 Nov 2010 12:15:00 +0000 (07:15 -0500)
If modules contain circular dependencies, the depmod script will follow
the circle forever.  So add a simple sanity check to abort rather than
chew up the CPU.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
examples/depmod.pl

index 8c6548d..f324b12 100755 (executable)
@@ -173,6 +173,9 @@ sub add_mod_deps
 
        $depth .= " ";
        warn "${depth}loading deps of module: $this_module\n" if $verbose;
+       if (length($depth) > 50) {
+               die "too much recursion (circular dependencies in modules?)";
+       }
 
        foreach my $md (keys %{$mod->{$this_module}}) {
                add_mod_deps ($depth, $mod, $mod2, $module, $md);