From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Subject: Re: problem with http clone/pull
Date: Tue, 12 Sep 2006 17:39:06 -0700 [thread overview]
Message-ID: <7vvensd2hh.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7v7j08eikw.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Tue, 12 Sep 2006 17:06:07 -0700")
Junio C Hamano <junkio@cox.net> writes:
> Perhaps this would fix it?
>
> I am at work now and I haven't looked at the logic aruond it
> too deeply (e.g. I do not know if this breaks the relative
> alternate or http specific cases, nor the same or similar
> breakages were there in these other cases in the original code
> to begin with)
Side note:
> diff --git a/http-fetch.c b/http-fetch.c
> index fac1760..d870390 100644
> --- a/http-fetch.c
> +++ b/http-fetch.c
> @@ -559,7 +559,13 @@ static void process_alternates_response(
> char *target = NULL;
> char *path;
> if (data[i] == '/') {
> - serverlen = strchr(base + 8, '/') - base;
> + /* This counts
> + * http://git.host/pub/scm/linux.git
> + * 1234567----here^
> + * so strcpy(dst, base, serverlen) will
> + * copy up to "...git.host/"
> + */
> + serverlen = strchr(base + 7, '/') - base;
> okay = 1;
> } else if (!memcmp(data + i, "../", 3)) {
> i += 3;
The change between 7 and 8 does not really matter, because the
hostname cannot be empty, and 8 was masking the breakage of this
code; it was (perhaps deliberately) being sloppy to allow us to
also skip over "protocol://" part for https:// case. Call it
subtle if you want ;-).
I think the right thing for this part to do would be something
like this:
diff --git a/http-fetch.c b/http-fetch.c
index fac1760..c7545f2 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -559,8 +559,18 @@ static void process_alternates_response(
char *target = NULL;
char *path;
if (data[i] == '/') {
- serverlen = strchr(base + 8, '/') - base;
- okay = 1;
+ /* This counts
+ * http://git.host/pub/scm/linux.git
+ * -----------here^
+ * so memcpy(dst, base, serverlen) will
+ * copy up to "...git.host".
+ */
+ const char *colon_ss = strstr(base,"://");
+ if (colon_ss) {
+ serverlen = (strchr(colon_ss + 3, '/')
+ - base);
+ okay = 1;
+ }
} else if (!memcmp(data + i, "../", 3)) {
i += 3;
serverlen = strlen(base);
@@ -583,11 +593,13 @@ static void process_alternates_response(
okay = 1;
}
}
- /* skip 'objects' at end */
+ /* skip "objects\n" at end */
if (okay) {
target = xmalloc(serverlen + posn - i - 6);
- strlcpy(target, base, serverlen);
- strlcpy(target + serverlen, data + i, posn - i - 6);
+ memcpy(target, base, serverlen);
+ memcpy(target + serverlen, data + i,
+ posn - i - 7);
+ target[serverlen + posn - i - 7] = 0;
if (get_verbosely)
fprintf(stderr,
"Also look at %s\n", target);
next prev parent reply other threads:[~2006-09-13 0:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-12 23:23 problem with http clone/pull Paul Mackerras
2006-09-12 23:43 ` Junio C Hamano
2006-09-13 0:06 ` Junio C Hamano
2006-09-13 0:39 ` Junio C Hamano [this message]
2006-09-13 1:08 ` Paul Mackerras
2006-09-13 19:03 ` 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=7vvensd2hh.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
/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