[PATCH v2 4/5] run_hook(): check the executability of the hook before filling argv

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Stephan Beyer <s-beyer@xxxxxxx>
---

	I hope this does not need any more words.
	Thanks to Dscho for the hint: it also saves a "free(argv)"
	and some { } for patch 5/5. :-)

 run-command.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/run-command.c b/run-command.c
index 49810a8..fc54c07 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;
-- 
1.6.1.160.gecdb

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux