From: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
To: marcelo.jimenez@gmail.com
Cc: git@vger.kernel.org
Subject: [PATCH] gitweb: Fixes error handling when reading configuration
Date: Wed, 10 Jan 2024 19:05:06 -0300 [thread overview]
Message-ID: <20240110220506.27491-1-marcelo.jimenez@gmail.com> (raw)
In-Reply-To: <CACjc_5pdijCZrrXQWHswsxYrGUzZ7pZq+nj3SzY1z+Xxop64Ww@mail.gmail.com>
This patch fixes a possibility of a permission to access error go
unnoticed.
Perl uses two different variables to manage errors from a do. 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.
By printing the value of $! I found out that it was set to Permission
denied. Since the script does not currently test for $!, the error
goes unnoticed.
Perl do block documentation: https://perldoc.perl.org/functions/do
Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
---
gitweb/gitweb.perl | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e66eb3d9ba..47577ec566 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -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;
}
--
2.43.0
next prev parent reply other threads:[~2024-01-10 22:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 0:43 Problem in gitweb.cgi Marcelo Roberto Jimenez
2024-01-10 22:05 ` Marcelo Roberto Jimenez [this message]
2024-01-10 22:57 ` [PATCH v2] gitweb: Fixes error handling when reading configuration Marcelo Roberto Jimenez
2024-01-11 0:17 ` Junio C Hamano
2024-01-11 2:14 ` Marcelo Roberto Jimenez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240110220506.27491-1-marcelo.jimenez@gmail.com \
--to=marcelo.jimenez@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).