git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Cc: Marcel Holtmann <marcel@holtmann.org>,
	Peter Baumann <peter.baumann@gmail.com>,
	merlyn@stonehenge.com (Randal L. Schwartz),
	Luben Tuikov <ltuikov@yahoo.com>
Subject: Re: Am I doing something wrong?
Date: Wed, 21 Dec 2005 11:58:30 -0800	[thread overview]
Message-ID: <7vvexi8bo9.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vhd92b90w.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Wed, 21 Dec 2005 10:27:27 -0800")

It turns out to be a stupid off-by-one error in http-fetch.c.
The objects/info/packs file has the following:

        $ cat objects/info/packs
        P pack-46ff81b11ed16ed38caa4aada913cb08c00185b2.pack
        P pack-05f611b3b8198b262acdf678584d365f8e879aec.pack
        P pack-740c99c0be6734adbd130737dec2608dc4682761.pack
        $

The code that parses this in http-fetch had an off-by-one, and
incorrectly thought that the last entry was incomplete.  This
problem did not surface earlier, because objects/info/packs file
used to have other information after all the P lines, but
http-fetch was not interested in was skipping them.  The latest
update-server-info stopped producing those extra lines.

As a band-aid, I just ran this command at the server that public
ones mirror from:

	$ echo >>objects/info/packs

The change seems to have mirrored out already, and my "broken"
client before the attached patch successfully fetches from
there, so hopefully things would work OK for you as well.

I also have to add some code to server-info.c, to append an
empty after objects/info/packs file to work around this bug in
the deployed http clients.

Thanks for your help in diagnosing and fixing this problem.

-- >8 --
[PATCH] http-fetch.c: fix objects/info/pack parsing.

It failed to register the last pack mentioned in the
objects/info/packs file.  Also it had an independent overrun
error.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---
git diff
diff --git a/http-fetch.c b/http-fetch.c
index ad59f1c..3cd6ef9 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -658,7 +658,7 @@ static int fetch_indices(struct alt_base
 		switch (data[i]) {
 		case 'P':
 			i++;
-			if (i + 52 < buffer.posn &&
+			if (i + 52 <= buffer.posn &&
 			    !strncmp(data + i, " pack-", 6) &&
 			    !strncmp(data + i + 46, ".pack\n", 6)) {
 				get_sha1_hex(data + i + 6, sha1);
@@ -667,7 +667,7 @@ static int fetch_indices(struct alt_base
 				break;
 			}
 		default:
-			while (data[i] != '\n')
+			while (i < buffer.posn && data[i] != '\n')
 				i++;
 		}
 		i++;

Compilation finished at Wed Dec 21 11:40:06

  parent reply	other threads:[~2005-12-21 19:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-21 16:51 Am I doing something wrong? Randal L. Schwartz
2005-12-21 17:52 ` Junio C Hamano
2005-12-21 17:54   ` Randal L. Schwartz
2005-12-21 18:07     ` Junio C Hamano
2005-12-21 18:17       ` Randal L. Schwartz
2005-12-21 18:27         ` Junio C Hamano
2005-12-21 18:37           ` Peter Baumann
2005-12-21 18:53             ` Peter Baumann
2005-12-21 19:58           ` Junio C Hamano [this message]
2005-12-21 21:03             ` Chuck Lever
2005-12-21 21:13               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vvexi8bo9.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=ltuikov@yahoo.com \
    --cc=marcel@holtmann.org \
    --cc=merlyn@stonehenge.com \
    --cc=peter.baumann@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).