Merge branch 'maint-1.6.4' into maint-1.6.5
authorJunio C Hamano <gitster@pobox.com>
Mon, 26 Jul 2010 04:51:58 +0000 (21:51 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Jul 2010 04:51:58 +0000 (21:51 -0700)
* maint-1.6.4:
Check size of path buffer before writing into it
rev-parse: fix --parse-opt --keep-dashdash --stop-at-non-option

1  2 
setup.c
diff --combined setup.c
index 4272ec0ef2fd833923a5303286a0dd237ec6eab8,01e1a6a7c5cb23909a8cc5050a1f7470abfff9eb..a614f125c30392cee59c1efa5c7bafb472c6e38a
+++ 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))