@matheusbsbs / matheus-bagliano / commits / 1c23d794bf
Fork 0

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>

Shawn O. Pearce committed Jan 9, 2007 at 20:04 UTC 1c23d794bfa3b9f3e03b18bb7e542615a924dbe3
2 files changed +4
http-fetch.c
+1
@@ -809,6 +809,7 @@ static int fetch_pack(struct alt_base *repo, unsigned char *sha1)
809 return error("Unable to start request");
810 }
811
812 + target->pack_size = ftell(packfile);
813 fclose(packfile);
814
815 ret = move_temp_to_file(tmpfile, filename);
http-push.c
+3
@@ -770,11 +770,14 @@ static void finish_request(struct transfer_request *request)
770 request->url, curl_errorstr);
771 remote->can_update_info_refs = 0;
772 } else {
773 + off_t pack_size = ftell(request->local_stream);
774 +
775 fclose(request->local_stream);
776 request->local_stream = NULL;
777 if (!move_temp_to_file(request->tmpfile,
778 request->filename)) {
779 target = (struct packed_git *)request->userData;
780 + target->pack_size = pack_size;
781 lst = &remote->packs;
782 while (*lst != target)
783 lst = &((*lst)->next);