@matheusbsbs / matheus-bagliano / commits / cf94ca8ea9
Fork 0

run_hook(): check the executability of the hook before filling argv

Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephan Beyer committed Jan 16, 2009 at 20:10 UTC cf94ca8ea98373d6f5e9caaa764eca89b20bfb63
1 file changed +3 -3
run-command.c
+3 -3
@@ -352,6 +352,9 @@ int run_hook(const char *index_file, const char *name, ...)
352 int ret;
353 int i;
354
355 + if (access(git_path("hooks/%s", name), X_OK) < 0)
356 + return 0;
357 +
358 va_start(args, name);
359 argv[0] = git_path("hooks/%s", name);
360 i = 0;
@@ -362,9 +365,6 @@ int run_hook(const char *index_file, const char *name, ...)
365 } while (argv[i]);
366 va_end(args);
367
365 - if (access(argv[0], X_OK) < 0)
366 - return 0;
367 -
368 memset(&hook, 0, sizeof(hook));
369 hook.argv = argv;
370 hook.no_stdin = 1;