Skip to content

Commit

Permalink
gitweb: die when a configuration file cannot be read
Browse files Browse the repository at this point in the history
Fix a possibility of a permission to access error go unnoticed.

Perl uses two different variables to manage errors from a "do
$filename" construct. One is $@, which is set in this case when do
is unable to compile the file. The other is $!, which is set in case
do cannot read the file.  The current code only checks "$@", which
means a configuration file passed to GitWeb that is not readable by
the server process does not cause it to "die".

Make sure we also check and act on "$!" to fix this.

Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
mrjimenez authored and gitster committed Jan 11, 2024
1 parent 564d025 commit ac62a36
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,11 @@ sub filter_and_validate_refs {
sub read_config_file {
my $filename = shift;
return unless defined $filename;
# die if there are errors parsing config file
if (-e $filename) {
do $filename;
# die if there is a problem accessing the file
die $! if $!;
# die if there are errors parsing config file
die $@ if $@;
return 1;
}
Expand Down

0 comments on commit ac62a36

Please sign in to comment.