From 200be6b810f930520ecee933b3e5a9b1d3a9489e Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Sat, 15 Oct 2022 20:02:16 -0500 Subject: [PATCH] Use symbolic constant for maximum directory depth --- gatekeeper.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 16ccac9..837dfe0 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -468,6 +468,9 @@ use constant MAX_FILE_NAME_LEN => 100; use constant MAX_DIRECTIVE_SIZE => 50*1024; # 50 KiB use constant MAX_SIGNATURE_SIZE => 50*1024; # 50 KiB +# limit on the number of subdirectories allowed +use constant MAX_DIRECTORY_DEPTH => 4; + # # -- Configuration sanity check # @@ -1110,7 +1113,7 @@ sub parse_directory_line { # 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 > 3 and not $do_not_fail); + if ($slash_count > (MAX_DIRECTORY_DEPTH-1) and not $do_not_fail); # Only let them specify one directory directive. fatal("Only one directory directive is allowed per directive file. " -- 2.25.1