From: Jacob Bachmeyer Date: Sun, 16 Oct 2022 01:07:24 +0000 (-0500) Subject: Use File::Spec::Unix to count directories in parse_directory_line X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e77d30fe2031d9fd0d483c7218b268d3f7a059c5;p=gatekeeper.git Use File::Spec::Unix to count directories in parse_directory_line --- diff --git a/gatekeeper.pl b/gatekeeper.pl index 837dfe0..5e2d2e0 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -1110,10 +1110,12 @@ sub parse_directory_line { 1,$directive_file_contents); my $val = $1; # so far so good + my @dirs = File::Spec::Unix->splitdir($1); + my $dir_depth = scalar @dirs; + # A couple of subdir levels are ok, but don't allow hundreds. - my $slash_count = ($val =~ tr,/,/,); - fatal("$slash_count slashes is too many, in $val",1,$directive_file_contents) - if ($slash_count > (MAX_DIRECTORY_DEPTH-1) and not $do_not_fail); + fatal("$dir_depth levels is too deep, in $val",1,$directive_file_contents) + if ($dir_depth > MAX_DIRECTORY_DEPTH and not $do_not_fail); # Only let them specify one directory directive. fatal("Only one directory directive is allowed per directive file. " diff --git a/testsuite/lib/gatekeeper.exp b/testsuite/lib/gatekeeper.exp index e84d263..236b1e4 100644 --- a/testsuite/lib/gatekeeper.exp +++ b/testsuite/lib/gatekeeper.exp @@ -627,7 +627,7 @@ proc analyze_log { base_dir name assess } { exp_continue } -re {^gatekeeper\[[0-9]+\]: \(Test\)\ - ([0-9]+) slashes is too many, in [^\r\n]+} { + ([0-9]+) levels is too deep, in [^\r\n]+} { # from parse_directory_line, when the directory is too deep set A(validate,bad-directory-depth) 1 set A(validate,bad-directory-depth,$expect_out(1,string)) 1