From: Stephan Beyer Date: Fri, 16 Jan 2009 19:10:01 +0000 (+0100) Subject: run_hook(): check the executability of the hook before filling argv X-Git-Tag: v1.6.2-rc0~108^2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/cf94ca8ea98373d6f5e9caaa764eca89b20bfb63?hp=35d5ae679c2a6bc2a5f70f9209844ae8c14ae9e3 run_hook(): check the executability of the hook before filling argv Signed-off-by: Stephan Beyer Signed-off-by: Junio C Hamano --- diff --git a/run-command.c b/run-command.c index 49810a835e..fc54c07a93 100644 --- a/run-command.c +++ b/run-command.c @@ -352,6 +352,9 @@ int run_hook(const char *index_file, const char *name, ...) int ret; int i; + if (access(git_path("hooks/%s", name), X_OK) < 0) + return 0; + va_start(args, name); argv[0] = git_path("hooks/%s", name); i = 0; @@ -362,9 +365,6 @@ int run_hook(const char *index_file, const char *name, ...) } while (argv[i]); va_end(args); - if (access(argv[0], X_OK) < 0) - return 0; - memset(&hook, 0, sizeof(hook)); hook.argv = argv; hook.no_stdin = 1;