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

[PATCH] init: Do not segfault on big GIT_TEMPLATE_DIR environment variable

From
Frank Lichtenheld <frank@lichtenheld.de>
Date
Apr 18, 2009, 14:14 UTC
Message-ID
<1240064042-22539-1-git-send-email-frank@lichtenheld.de>
From: Frank Lichtenheld <flichtenheld@astaro.com>
Signed-off-by: Frank Lichtenheld <flichtenheld@astaro.com>
---
 builtin-init-db.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 4e02b33..d1fa12a 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -122,8 +122,10 @@ static void copy_templates(const char *template_dir)
 		template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
 	if (!template_dir[0])
 		return;
+	template_len = strlen(template_dir);
+	if (PATH_MAX <= (template_len+strlen("/config")))
+		die("insanely long template path %s", template_dir);
 	strcpy(template_path, template_dir);
-	template_len = strlen(template_path);
 	if (template_path[template_len-1] != '/') {
 		template_path[template_len++] = '/';
 		template_path[template_len] = 0;
-- 
1.6.2.1
Message 1 of 1 in “init: Do not segfault on big GIT_TEMPLATE_DIR environment variable”
  1. init: Do not segfault on big GIT_TEMPLATE_DIR environment variableFrank Lichtenheld, Apr 18, 2009

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.