summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 53ffb87)
raw | patch | inline | side by side (parent: 53ffb87)
author | Junio C Hamano <gitster@pobox.com> | |
Sun, 26 Oct 2008 18:07:18 +0000 (11:07 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 26 Oct 2008 21:05:55 +0000 (14:05 -0700) |
In the alternate_object_database structure, ent->base[] is a buffer the
users can use to form pathnames to loose objects, and ent->name is a
pointer into that buffer (it points at one beyond ".git/objects/"). If
you get a call to add_refs_from_alternate() after somebody used the entry
(has_loose_object() has been called, for example), *ent->name would not be
NUL, and ent->base[] won't be the path to the object store.
This caller is expecting to read the path to the object store in ent->base[];
it needs to NUL terminate the buffer if it wants to.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
users can use to form pathnames to loose objects, and ent->name is a
pointer into that buffer (it points at one beyond ".git/objects/"). If
you get a call to add_refs_from_alternate() after somebody used the entry
(has_loose_object() has been called, for example), *ent->name would not be
NUL, and ent->base[] won't be the path to the object store.
This caller is expecting to read the path to the object store in ent->base[];
it needs to NUL terminate the buffer if it wants to.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-receive-pack.c | patch | blob | history |
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c
index 45e3cd90fd476cdb0a32e5de27739b18e060e031..9f60f31c2bb7da7095de8d692d215c485ab5da0c 100644 (file)
--- a/builtin-receive-pack.c
+++ b/builtin-receive-pack.c
static int add_refs_from_alternate(struct alternate_object_database *e, void *unused)
{
- char *other = xstrdup(make_absolute_path(e->base));
- size_t len = strlen(other);
+ char *other;
+ size_t len;
struct remote *remote;
struct transport *transport;
const struct ref *extra;
+ e->name[-1] = '\0';
+ other = xstrdup(make_absolute_path(e->base));
+ e->name[-1] = '/';
+ len = strlen(other);
+
while (other[len-1] == '/')
other[--len] = '\0';
if (len < 8 || memcmp(other + len - 8, "/objects", 8))