git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb: Fixes error handling when reading configuration

From
Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
Date
Jan 10, 2024, 22:05 UTC
Message-ID
<20240110220506.27491-1-marcelo.jimenez@gmail.com>
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
Previous: Marcelo Roberto JimenezNext: Marcelo Roberto Jimenez
Message 2 of 5 in “Problem in gitweb.cgi”
  1. Marcelo Roberto JimenezJan 10, 2024
  2. gitweb: Fixes error handling when reading configurationMarcelo Roberto Jimenez, Jan 10, 2024
  3. gitweb: Fixes error handling when reading configurationMarcelo Roberto Jimenez, Jan 10, 2024
  4. Junio C HamanoJan 11, 2024
  5. Marcelo Roberto JimenezJan 11, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.