{"thread":{"id":"6322","subject":"[PATCH] Don't die in git-http-fetch when fetching packs.","startedAt":"2007-01-10T01:04:52Z","lastAt":"2007-01-10T01:28:01Z","messageCount":3,"participants":["Shawn O. Pearce","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"31339","messageId":"20070110010452.GA30610@spearce.org","threadId":"6322","inReplyTo":null,"subject":"[PATCH] Don't die in git-http-fetch when fetching packs.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-01-10T01:04:52Z","receivedAt":"2007-01-10T01:04:52Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"My sp/mmap changes to pack-check.c modified the function such that\nit expects packed_git.pack_size to be populated with the total\nbytecount of the packfile by the caller.\n\nBut that isn't the case for packs obtained by git-http-fetch as\npack_size was not initialized before being accessed.  This caused\nverify_pack to think it had 2^32-21 bytes available when the\ndownloaded pack perhaps was only 305 bytes in length.  The use_pack\nfunction then later dies with \"offset beyond end of packfile\"\nwhen computing the overall file checksum.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n For the tip of my sp/mmap topic.  Without it HTTP fetch and push\n support is severely broken as it cannot deal with packs.\n\n http-fetch.c |    1 +\n http-push.c  |    1 +\n 2 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/http-fetch.c b/http-fetch.c\nindex fe8cd7b..67dfb0a 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -809,6 +809,7 @@ static int fetch_pack(struct alt_base *repo, unsigned char *sha1)\n \t\treturn error(\"Unable to start request\");\n \t}\n \n+\ttarget->pack_size = ftell(packfile);\n \tfclose(packfile);\n \n \tret = move_temp_to_file(tmpfile, filename);\ndiff --git a/http-push.c b/http-push.c\nindex 7e73eac..8eb448e 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -770,6 +770,7 @@ static void finish_request(struct transfer_request *request)\n \t\t\t\trequest->url, curl_errorstr);\n \t\t\tremote->can_update_info_refs = 0;\n \t\t} else {\n+\t\t\ttarget->pack_size = ftell(request->local_stream);\n \t\t\tfclose(request->local_stream);\n \t\t\trequest->local_stream = NULL;\n \t\t\tif (!move_temp_to_file(request->tmpfile,\n-- \n1.4.4.4.gf198\n"},{"id":"31341","messageId":"7v1wm3hekz.fsf@assigned-by-dhcp.cox.net","threadId":"6322","inReplyTo":"20070110010452.GA30610@spearce.org","subject":"Re: [PATCH] Don't die in git-http-fetch when fetching packs.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-10T01:10:04Z","receivedAt":"2007-01-10T01:10:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> My sp/mmap changes to pack-check.c modified the function such that\n> it expects packed_git.pack_size to be populated with the total\n> bytecount of the packfile by the caller.\n>\n> But that isn't the case for packs obtained by git-http-fetch as\n> pack_size was not initialized before being accessed.  This caused\n> verify_pack to think it had 2^32-21 bytes available when the\n> downloaded pack perhaps was only 305 bytes in length.  The use_pack\n> function then later dies with \"offset beyond end of packfile\"\n> when computing the overall file checksum.\n>\n> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>\n> ---\n>\n>  For the tip of my sp/mmap topic.  Without it HTTP fetch and push\n>  support is severely broken as it cannot deal with packs.\n\nAh, thanks.  I've seen this today and a repeated fetch after\nthat fixed it and thought it was a mirroring lag.\n"},{"id":"31346","messageId":"20070110012801.GA30703@spearce.org","threadId":"6322","inReplyTo":"7v1wm3hekz.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Don't die in git-http-fetch when fetching packs.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-01-10T01:28:01Z","receivedAt":"2007-01-10T01:28:01Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> >  For the tip of my sp/mmap topic.  Without it HTTP fetch and push\n> >  support is severely broken as it cannot deal with packs.\n> \n> Ah, thanks.  I've seen this today and a repeated fetch after\n> that fixed it and thought it was a mirroring lag.\n\nMe too.  I have actually been fighting with it on and off since we\ngot sp/mmap reasonably stable.  I just always kept attributing it\nto kernel.org mirroring lag until I realized it was just happening\nway too often.\n\n-- \nShawn.\n"}]}