diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2007-01-09 20:04:52 -0500 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-01-09 17:54:25 -0800 |
commit | 1c23d794bfa3b9f3e03b18bb7e542615a924dbe3 (patch) | |
tree | fd04e34a716ecabee7eab283ffecb22f0b6fdee1 | |
parent | cec21ca7cfd5d8fd19ea87e15f14dce6ee3b3859 (diff) | |
download | git-1c23d794bfa3b9f3e03b18bb7e542615a924dbe3.tar.gz |
Don't die in git-http-fetch when fetching packs.
My sp/mmap changes to pack-check.c modified the function such that
it expects packed_git.pack_size to be populated with the total
bytecount of the packfile by the caller.
But that isn't the case for packs obtained by git-http-fetch as
pack_size was not initialized before being accessed. This caused
verify_pack to think it had 2^32-21 bytes available when the
downloaded pack perhaps was only 305 bytes in length. The use_pack
function then later dies with "offset beyond end of packfile"
when computing the overall file checksum.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r-- | http-fetch.c | 1 | ||||
-rw-r--r-- | http-push.c | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/http-fetch.c b/http-fetch.c index fe8cd7bdcd..67dfb0a033 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -809,6 +809,7 @@ static int fetch_pack(struct alt_base *repo, unsigned char *sha1) return error("Unable to start request"); } + target->pack_size = ftell(packfile); fclose(packfile); ret = move_temp_to_file(tmpfile, filename); diff --git a/http-push.c b/http-push.c index 7e73eac9c3..0a15f53782 100644 --- a/http-push.c +++ b/http-push.c @@ -770,11 +770,14 @@ static void finish_request(struct transfer_request *request) request->url, curl_errorstr); remote->can_update_info_refs = 0; } else { + off_t pack_size = ftell(request->local_stream); + fclose(request->local_stream); request->local_stream = NULL; if (!move_temp_to_file(request->tmpfile, request->filename)) { target = (struct packed_git *)request->userData; + target->pack_size = pack_size; lst = &remote->packs; while (*lst != target) lst = &((*lst)->next); |