Skip to contentSkip to conversation

scripts/get_maintainer.pl: Fix possible infinite loop

PATCH Superseded Joe Perches 1 participant 2 messages Feb 23, 2010 GET_MAINTAINER script

lore
Share & tools
lore

Joe Perches

author maintainer
#0 lore raw

PATCH 1/1 scripts/get_maintainer.pl: Fix possible infinite loop

If MAINTAINERS section entries are misformatted,
it was possible to have an infinite loop.

Correct the defect by always moving at least one entry forward in parsing the MAINTAINERS file.

---
 scripts/get_maintainer.pl |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
scripts/get_maintainer.pl +5 -2
index 2f3230d..4f2ec25 100755
@@ -340,8 +340,11 @@ foreach my $file (@files) {
 	    }
 	}
 
-	$tvi += ($end - $start);
-
+	if ($end <= $start) {
+	    $tvi++;
+	} else {
+	    $tvi += ($end - $start);
+	}
     }
 
     foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
Signature · 1 line
1.7.0.14.g7e948
author maintainer
#1 lore raw

PATCH v2 1/1 scripts/get_maintainer.pl: Fix possible infinite loop

This is simpler.

If MAINTAINERS section entries are misformatted,
it was possible to have an infinite loop.

Correct the defect by always moving the index
to the end of section + 1

Also, exit check for exclude as soon as possible.

 scripts/get_maintainer.pl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
scripts/get_maintainer.pl +2 -2
index 2f3230d..049c419 100755
@@ -314,6 +314,7 @@ foreach my $file (@files) {
 		if ($type eq 'X') {
 		    if (file_match_pattern($file, $value)) {
 			$exclude = 1;
+			last;
 		    }
 		}
 	    }
@@ -340,8 +341,7 @@ foreach my $file (@files) {
 	    }
 	}
 
-	$tvi += ($end - $start);
-
+	$tvi = $end + 1;
     }
 
     foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {