summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 319aae2)
raw | patch | inline | side by side (parent: 319aae2)
author | Linus Torvalds <torvalds@g5.osdl.org> | |
Wed, 6 Jul 2005 01:10:59 +0000 (18:10 -0700) | ||
committer | Linus Torvalds <torvalds@g5.osdl.org> | |
Wed, 6 Jul 2005 01:10:59 +0000 (18:10 -0700) |
GIT_DIR=. ends up being what some of the pack senders use, and we
sometimes messed up when cleaning up the path, ie a ".//HEAD" was
cleaned up into "/HEAD", not "HEAD" like it should be.
We should do some other cleanup, and probably also verify that symlinks
don't point to outside the git area.
sometimes messed up when cleaning up the path, ie a ".//HEAD" was
cleaned up into "/HEAD", not "HEAD" like it should be.
We should do some other cleanup, and probably also verify that symlinks
don't point to outside the git area.
sha1_file.c | patch | blob | history |
diff --git a/sha1_file.c b/sha1_file.c
index 74dc2aab26c0e9f87e9238686ad0a077b1570d4a..bbb749c561ebfe6cff8240f99b8902e526dda368 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
char *git_path(const char *fmt, ...)
{
- static char pathname[PATH_MAX];
+ static char pathname[PATH_MAX], *ret;
va_list args;
int len;
if (!git_dir)
setup_git_env();
len = strlen(git_dir);
- if (len == 1 && *git_dir == '.')
- len = 0;
if (len > PATH_MAX-100)
return "pad-path";
memcpy(pathname, git_dir, len);
va_start(args, fmt);
vsnprintf(pathname + len, sizeof(pathname) - len, fmt, args);
va_end(args);
- return pathname;
+ ret = pathname;
+
+ /* Clean it up */
+ if (!memcmp(pathname, "./", 2)) {
+ ret += 2;
+ while (*ret == '/')
+ ret++;
+ }
+ return ret;
}
int get_sha1(const char *str, unsigned char *sha1)