File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -122,8 +122,10 @@ static void copy_templates(const char *template_dir)
122122 template_dir = system_path (DEFAULT_GIT_TEMPLATE_DIR );
123123 if (!template_dir [0 ])
124124 return ;
125+ template_len = strlen (template_dir );
126+ if (PATH_MAX <= (template_len + strlen ("/config" )))
127+ die ("insanely long template path %s" , template_dir );
125128 strcpy (template_path , template_dir );
126- template_len = strlen (template_path );
127129 if (template_path [template_len - 1 ] != '/' ) {
128130 template_path [template_len ++ ] = '/' ;
129131 template_path [template_len ] = 0 ;
Original file line number Diff line number Diff line change @@ -199,4 +199,13 @@ test_expect_success 'init honors global core.sharedRepository' '
199199 x`git config -f shared-honor-global/.git/config core.sharedRepository`
200200'
201201
202+ test_expect_success ' init rejects insanely long --template' '
203+ (
204+ insane=$(printf "x%09999dx" 1) &&
205+ mkdir test &&
206+ cd test &&
207+ test_must_fail git init --template=$insane
208+ )
209+ '
210+
202211test_done
You can’t perform that action at this time.
0 commit comments