X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=setup.c;h=276916052795c5ffa872b57a7e6723edc71dfdc4;hb=21746aa34fc99d2c73634bc9829387c27c109dbe;hp=5a083fa77dda016d0f3f511787ebf771aaf1be08;hpb=4d544948167c577eff2a41df906e1ef89b36faee;p=git.git diff --git a/setup.c b/setup.c index 5a083fa77..276916052 100644 --- a/setup.c +++ b/setup.c @@ -170,6 +170,8 @@ static int is_git_directory(const char *suspect) 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)) @@ -323,7 +325,8 @@ const char *setup_git_directory_gently(int *nongit_ok) const char *gitdirenv; const char *gitfile_dir; int len, offset, ceil_offset, root_len; - int current_device = 0, one_filesystem = 1; + dev_t current_device = 0; + int one_filesystem = 1; struct stat buf; /* @@ -546,6 +549,12 @@ int check_repository_format(void) return check_repository_format_gently(NULL); } +/* + * Returns the "prefix", a path to the current working directory + * relative to the work tree root, or NULL, if the current working + * directory is not a strict subdirectory of the work tree root. The + * prefix always ends with a '/' character. + */ const char *setup_git_directory(void) { const char *retval = setup_git_directory_gently(NULL);