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)
122
122
template_dir = system_path (DEFAULT_GIT_TEMPLATE_DIR );
123
123
if (!template_dir [0 ])
124
124
return ;
125
+ template_len = strlen (template_dir );
126
+ if (PATH_MAX <= (template_len + strlen ("/config" )))
127
+ die ("insanely long template path %s" , template_dir );
125
128
strcpy (template_path , template_dir );
126
- template_len = strlen (template_path );
127
129
if (template_path [template_len - 1 ] != '/' ) {
128
130
template_path [template_len ++ ] = '/' ;
129
131
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' '
199
199
x`git config -f shared-honor-global/.git/config core.sharedRepository`
200
200
'
201
201
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
+
202
211
test_done
You can’t perform that action at this time.
0 commit comments