[PATCH 2/2] cgit: sanitize max-repo-count

Christian Hesse list at eworm.de
Mon Jan 7 16:35:35 CET 2019


From: Christian Hesse <mail at eworm.de>

Setting max-repo-count to "0" makes cgit loop forever generating page
links. Make this a special value to show all repositories.

Signed-off-by: Christian Hesse <mail at eworm.de>
---
 cgit.c       | 2 +-
 cgitrc.5.txt | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/cgit.c b/cgit.c
index cc953a7..a09e3c7 100644
--- a/cgit.c
+++ b/cgit.c
@@ -241,7 +241,7 @@ static void config_cb(const char *name, const char *value)
 	else if (!strcmp(name, "max-blob-size"))
 		ctx.cfg.max_blob_size = parse_int(value, 0, INT_MAX, 0);
 	else if (!strcmp(name, "max-repo-count"))
-		ctx.cfg.max_repo_count = parse_int(value, 0, INT_MAX, 0);
+		ctx.cfg.max_repo_count = parse_int(value, 0, INT_MAX, INT_MAX);
 	else if (!strcmp(name, "max-commit-count"))
 		ctx.cfg.max_commit_count = parse_int(value, 0, INT_MAX, 0);
 	else if (!strcmp(name, "project-list"))
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 34b351b..1731fda 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -269,7 +269,8 @@ max-message-length::
 
 max-repo-count::
 	Specifies the number of entries to list per page on the	repository
-	index page. Default value: "50".
+	index page. The value "0" shows all repositories without limitation.
+	Default value: "50".
 
 max-repodesc-length::
 	Specifies the maximum number of repo description characters to display


More information about the CGit mailing list