Skip to content

Commit cf94ca8

Browse files
sbeyergitster
authored andcommitted
run_hook(): check the executability of the hook before filling argv
Signed-off-by: Stephan Beyer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 35d5ae6 commit cf94ca8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

run-command.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ int run_hook(const char *index_file, const char *name, ...)
352352
int ret;
353353
int i;
354354

355+
if (access(git_path("hooks/%s", name), X_OK) < 0)
356+
return 0;
357+
355358
va_start(args, name);
356359
argv[0] = git_path("hooks/%s", name);
357360
i = 0;
@@ -362,9 +365,6 @@ int run_hook(const char *index_file, const char *name, ...)
362365
} while (argv[i]);
363366
va_end(args);
364367

365-
if (access(argv[0], X_OK) < 0)
366-
return 0;
367-
368368
memset(&hook, 0, sizeof(hook));
369369
hook.argv = argv;
370370
hook.no_stdin = 1;

0 commit comments

Comments
 (0)