{"thread":{"id":"18934","subject":"[PATCH] init: Do not segfault on big GIT_TEMPLATE_DIR environment variable","startedAt":"2009-04-18T14:14:02Z","lastAt":"2009-04-18T14:14:02Z","messageCount":1,"participants":["Frank Lichtenheld"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"111574","messageId":"1240064042-22539-1-git-send-email-frank@lichtenheld.de","threadId":"18934","inReplyTo":null,"subject":"[PATCH] init: Do not segfault on big GIT_TEMPLATE_DIR environment variable","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2009-04-18T14:14:02Z","receivedAt":"2009-04-18T14:14:02Z","isPatch":true,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"From: Frank Lichtenheld <flichtenheld@astaro.com>\n\nSigned-off-by: Frank Lichtenheld <flichtenheld@astaro.com>\n---\n builtin-init-db.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex 4e02b33..d1fa12a 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -122,8 +122,10 @@ static void copy_templates(const char *template_dir)\n \t\ttemplate_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);\n \tif (!template_dir[0])\n \t\treturn;\n+\ttemplate_len = strlen(template_dir);\n+\tif (PATH_MAX <= (template_len+strlen(\"/config\")))\n+\t\tdie(\"insanely long template path %s\", template_dir);\n \tstrcpy(template_path, template_dir);\n-\ttemplate_len = strlen(template_path);\n \tif (template_path[template_len-1] != '/') {\n \t\ttemplate_path[template_len++] = '/';\n \t\ttemplate_path[template_len] = 0;\n-- \n1.6.2.1\n"}]}