summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 347f1d2)
raw | patch | inline | side by side (parent: 347f1d2)
author | Dmitry V. Levin <ldv@altlinux.org> | |
Tue, 30 May 2006 14:58:52 +0000 (18:58 +0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 31 May 2006 04:47:29 +0000 (21:47 -0700) |
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
exec_cmd.c | patch | blob | history |
diff --git a/exec_cmd.c b/exec_cmd.c
index 44bb2f23de926db59832a69a3205a320dfe61c4d..12eb36494ca467169aff4db35335b3fdadd4cbee 100644 (file)
--- a/exec_cmd.c
+++ b/exec_cmd.c
int execv_git_cmd(const char **argv)
{
char git_command[PATH_MAX + 1];
- int len, i;
+ int i;
const char *paths[] = { current_exec_path,
getenv("GIT_EXEC_PATH"),
builtin_exec_path };
for (i = 0; i < ARRAY_SIZE(paths); ++i) {
+ size_t len;
+ int rc;
const char *exec_dir = paths[i];
const char *tmp;
if (*exec_dir != '/') {
if (!getcwd(git_command, sizeof(git_command))) {
fprintf(stderr, "git: cannot determine "
- "current directory\n");
- exit(1);
+ "current directory: %s\n",
+ strerror(errno));
+ break;
}
len = strlen(git_command);
while (*exec_dir == '/')
exec_dir++;
}
- snprintf(git_command + len, sizeof(git_command) - len,
- "/%s", exec_dir);
+
+ rc = snprintf(git_command + len,
+ sizeof(git_command) - len, "/%s",
+ exec_dir);
+ if (rc < 0 || rc >= sizeof(git_command) - len) {
+ fprintf(stderr, "git: command name given "
+ "is too long.\n");
+ break;
+ }
} else {
+ if (strlen(exec_dir) + 1 > sizeof(git_command)) {
+ fprintf(stderr, "git: command name given "
+ "is too long.\n");
+ break;
+ }
strcpy(git_command, exec_dir);
}
len = strlen(git_command);
- len += snprintf(git_command + len, sizeof(git_command) - len,
- "/git-%s", argv[0]);
-
- if (sizeof(git_command) <= len) {
+ rc = snprintf(git_command + len, sizeof(git_command) - len,
+ "/git-%s", argv[0]);
+ if (rc < 0 || rc >= sizeof(git_command) - len) {
fprintf(stderr,
"git: command name given is too long.\n");
break;