From: Marcelo Roberto Jimenez Date: Wed, 10 Jan 2024 22:57:09 +0000 (-0300) Subject: gitweb: die when a configuration file cannot be read X-Git-Tag: v2.44.0-rc0~57^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ac62a3649fcfd7f2caa80ffdfb8c3135764291ef;p=thirdparty%2Fgit.git gitweb: die when a configuration file cannot be read 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 Signed-off-by: Junio C Hamano --- diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index e66eb3d9ba..5d0122020f 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -728,9 +728,11 @@ our $per_request_config = 1; 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; }