From: Junio C Hamano Date: Mon, 26 Jul 2010 04:51:58 +0000 (-0700) Subject: Merge branch 'maint-1.6.4' into maint-1.6.5 X-Git-Tag: v1.6.5.9~2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a07b10c8f930e88386d3b7424f25190af554275e?ds=inline;hp=-c Merge branch 'maint-1.6.4' into maint-1.6.5 * maint-1.6.4: Check size of path buffer before writing into it rev-parse: fix --parse-opt --keep-dashdash --stop-at-non-option --- a07b10c8f930e88386d3b7424f25190af554275e diff --combined setup.c index 4272ec0ef2,01e1a6a7c5..a614f125c3 --- a/setup.c +++ b/setup.c @@@ -18,12 -18,9 +18,12 @@@ const char *prefix_path(const char *pre if (normalize_path_copy(sanitized, sanitized)) goto error_out; if (is_absolute_path(orig)) { + size_t len, total; const char *work_tree = get_git_work_tree(); - size_t len = strlen(work_tree); - size_t total = strlen(sanitized) + 1; + if (!work_tree) + goto error_out; + len = strlen(work_tree); + total = strlen(sanitized) + 1; if (strncmp(sanitized, work_tree, len) || (sanitized[len] != '\0' && sanitized[len] != '/')) { error_out: @@@ -44,7 -41,7 +44,7 @@@ const char *prefix_filename(const char *pfx, int pfx_len, const char *arg) { static char path[PATH_MAX]; -#ifndef __MINGW32__ +#ifndef WIN32 if (!pfx || !*pfx || is_absolute_path(arg)) return arg; memcpy(path, pfx, pfx_len); @@@ -156,6 -153,8 +156,8 @@@ static int is_git_directory(const char char path[PATH_MAX]; size_t len = strlen(suspect); + if (PATH_MAX <= len + strlen("/objects")) + die("Too long path: %.*s", 60, suspect); strcpy(path, suspect); if (getenv(DB_ENVIRONMENT)) { if (access(getenv(DB_ENVIRONMENT), X_OK))