{"thread":{"id":"5546","subject":"problem with http clone/pull","startedAt":"2006-09-12T23:23:17Z","lastAt":"2006-09-13T19:03:28Z","messageCount":6,"participants":["Paul Mackerras","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"26777","messageId":"17671.16741.995661.664789@cargo.ozlabs.ibm.com","threadId":"5546","inReplyTo":null,"subject":"problem with http clone/pull","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2006-09-12T23:23:17Z","receivedAt":"2006-09-12T23:23:17Z","isPatch":false,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Junio,\n\nUsers are having problems doing clones or pulls of my powerpc.git tree\non kernel.org with version 1.4.2 of git.  Apparently earlier versions\nwork OK.\n\nWhen I do:\n\ngit clone http://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git\n\nit produces the following output:\n\nGetting alternates list for http://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/\nAlso look at http://git.kernel.or\nerror: Couldn't resolve host 'git.kernel.orobjects' (curl_result = 6, http_code = 0, sha1 = c336923b668fdcf0312efbec3b44895d713f4d81)\nGetting pack list for http://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/\nGetting pack list for http://git.kernel.or\nerror: Couldn't resolve host 'git.kernel.or'\nerror: Unable to find c336923b668fdcf0312efbec3b44895d713f4d81 under http://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/\nCannot obtain needed none c336923b668fdcf0312efbec3b44895d713f4d81\nwhile processing commit 0000000000000000000000000000000000000000.\n\nNow, this repository has a objects/info/alternates file that contains\nthe single line:\n\n/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/objects\n\nI also have a hooks/post-update with execute permission, that does\nexec git-update-server-info.\n\nIs there anything obviously wrong in how I have set this up, or is it\na new bug in git 1.4.2?\n\nThanks,\nPaul.\n"},{"id":"26778","messageId":"7vodtkejm9.fsf@assigned-by-dhcp.cox.net","threadId":"5546","inReplyTo":"17671.16741.995661.664789@cargo.ozlabs.ibm.com","subject":"Re: problem with http clone/pull","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-12T23:43:42Z","receivedAt":"2006-09-12T23:43:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Mackerras <paulus@samba.org> writes:\n\n> Getting alternates list for http://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/\n> Also look at http://git.kernel.or\n> error: Couldn't resolve host 'git.kernel.orobjects' (curl_result = 6, http_code = 0, sha1 = c336923b668fdcf0312efbec3b44895d713f4d81)\n> Getting pack list for http://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/\n> Getting pack list for http://git.kernel.or\n\nI've seen this \"last character of hostname dropped\" symptom\nmentioned on the #git channel long time ago, but I do not\nremember if somebody figured out what the problem was.  I know\nthat nobody did a patch to specifically fix it.\n\nAmong the changes since v1.3.0 that touches http-fetch.c the\nonly thing I can see that touches anything related to alternates\nhandling is this one, but I do not see anything obviously wrong\nwith it X-<.\n\ncommit bfbd0bb6ecbbbf75a5caaff6afaf5a6af8fa518e\nDate:   Sun Jun 11 14:03:28 2006 +0200\n\n    Implement safe_strncpy() as strlcpy() and use it more.\n    \ndiff --git a/http-fetch.c b/http-fetch.c\nindex d3602b7..da1a7f5 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -584,10 +584,8 @@ static void process_alternates_response(\n \t\t\t// skip 'objects' at end\n \t\t\tif (okay) {\n \t\t\t\ttarget = xmalloc(serverlen + posn - i - 6);\n-\t\t\t\tstrncpy(target, base, serverlen);\n-\t\t\t\tstrncpy(target + serverlen, data + i,\n-\t\t\t\t\tposn - i - 7);\n-\t\t\t\ttarget[serverlen + posn - i - 7] = '\\0';\n+\t\t\t\tsafe_strncpy(target, base, serverlen);\n+\t\t\t\tsafe_strncpy(target + serverlen, data + i, posn - i - 6);\n \t\t\t\tif (get_verbosely)\n \t\t\t\t\tfprintf(stderr,\n \t\t\t\t\t\t\"Also look at %s\\n\", target);\n"},{"id":"26780","messageId":"7v7j08eikw.fsf@assigned-by-dhcp.cox.net","threadId":"5546","inReplyTo":"7vodtkejm9.fsf@assigned-by-dhcp.cox.net","subject":"Re: problem with http clone/pull","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-13T00:06:07Z","receivedAt":"2006-09-13T00:06:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> I've seen this \"last character of hostname dropped\" symptom\n> mentioned on the #git channel long time ago, but I do not\n> remember if somebody figured out what the problem was.  I know\n> that nobody did a patch to specifically fix it.\n\nPerhaps this would fix it?\n\nI am at work now and I haven't looked at the logic aruond it\ntoo deeply (e.g. I do not know if this breaks the relative\nalternate or http specific cases, nor the same or similar\nbreakages were there in these other cases in the original code\nto begin with)\n\n---\n\ndiff --git a/http-fetch.c b/http-fetch.c\nindex fac1760..d870390 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -559,7 +559,13 @@ static void process_alternates_response(\n \t\t\tchar *target = NULL;\n \t\t\tchar *path;\n \t\t\tif (data[i] == '/') {\n-\t\t\t\tserverlen = strchr(base + 8, '/') - base;\n+\t\t\t\t/* This counts\n+\t\t\t\t * http://git.host/pub/scm/linux.git\n+\t\t\t\t * 1234567----here^\n+\t\t\t\t * so strcpy(dst, base, serverlen) will\n+\t\t\t\t * copy up to \"...git.host/\"\n+\t\t\t\t */\n+\t\t\t\tserverlen = strchr(base + 7, '/') - base;\n \t\t\t\tokay = 1;\n \t\t\t} else if (!memcmp(data + i, \"../\", 3)) {\n \t\t\t\ti += 3;\n@@ -586,7 +592,7 @@ static void process_alternates_response(\n \t\t\t/* skip 'objects' at end */\n \t\t\tif (okay) {\n \t\t\t\ttarget = xmalloc(serverlen + posn - i - 6);\n-\t\t\t\tstrlcpy(target, base, serverlen);\n+\t\t\t\tmemcpy(target, base, serverlen);\n \t\t\t\tstrlcpy(target + serverlen, data + i, posn - i - 6);\n \t\t\t\tif (get_verbosely)\n \t\t\t\t\tfprintf(stderr,\n"},{"id":"26781","messageId":"7vvensd2hh.fsf@assigned-by-dhcp.cox.net","threadId":"5546","inReplyTo":"7v7j08eikw.fsf@assigned-by-dhcp.cox.net","subject":"Re: problem with http clone/pull","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-13T00:39:06Z","receivedAt":"2006-09-13T00:39:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> Perhaps this would fix it?\n>\n> I am at work now and I haven't looked at the logic aruond it\n> too deeply (e.g. I do not know if this breaks the relative\n> alternate or http specific cases, nor the same or similar\n> breakages were there in these other cases in the original code\n> to begin with)\n\nSide note:\n\n> diff --git a/http-fetch.c b/http-fetch.c\n> index fac1760..d870390 100644\n> --- a/http-fetch.c\n> +++ b/http-fetch.c\n> @@ -559,7 +559,13 @@ static void process_alternates_response(\n>  \t\t\tchar *target = NULL;\n>  \t\t\tchar *path;\n>  \t\t\tif (data[i] == '/') {\n> -\t\t\t\tserverlen = strchr(base + 8, '/') - base;\n> +\t\t\t\t/* This counts\n> +\t\t\t\t * http://git.host/pub/scm/linux.git\n> +\t\t\t\t * 1234567----here^\n> +\t\t\t\t * so strcpy(dst, base, serverlen) will\n> +\t\t\t\t * copy up to \"...git.host/\"\n> +\t\t\t\t */\n> +\t\t\t\tserverlen = strchr(base + 7, '/') - base;\n>  \t\t\t\tokay = 1;\n>  \t\t\t} else if (!memcmp(data + i, \"../\", 3)) {\n>  \t\t\t\ti += 3;\n\nThe change between 7 and 8 does not really matter, because the\nhostname cannot be empty, and 8 was masking the breakage of this\ncode; it was (perhaps deliberately) being sloppy to allow us to\nalso skip over \"protocol://\" part for https:// case.  Call it\nsubtle if you want ;-).\n\nI think the right thing for this part to do would be something\nlike this:\n\ndiff --git a/http-fetch.c b/http-fetch.c\nindex fac1760..c7545f2 100644\n--- a/http-fetch.c\n+++ b/http-fetch.c\n@@ -559,8 +559,18 @@ static void process_alternates_response(\n \t\t\tchar *target = NULL;\n \t\t\tchar *path;\n \t\t\tif (data[i] == '/') {\n-\t\t\t\tserverlen = strchr(base + 8, '/') - base;\n-\t\t\t\tokay = 1;\n+\t\t\t\t/* This counts\n+\t\t\t\t * http://git.host/pub/scm/linux.git\n+\t\t\t\t * -----------here^\n+\t\t\t\t * so memcpy(dst, base, serverlen) will\n+\t\t\t\t * copy up to \"...git.host\".\n+\t\t\t\t */\n+\t\t\t\tconst char *colon_ss = strstr(base,\"://\");\n+\t\t\t\tif (colon_ss) {\n+\t\t\t\t\tserverlen = (strchr(colon_ss + 3, '/')\n+\t\t\t\t\t\t     - base);\n+\t\t\t\t\tokay = 1;\n+\t\t\t\t}\n \t\t\t} else if (!memcmp(data + i, \"../\", 3)) {\n \t\t\t\ti += 3;\n \t\t\t\tserverlen = strlen(base);\n@@ -583,11 +593,13 @@ static void process_alternates_response(\n \t\t\t\t\tokay = 1;\n \t\t\t\t}\n \t\t\t}\n-\t\t\t/* skip 'objects' at end */\n+\t\t\t/* skip \"objects\\n\" at end */\n \t\t\tif (okay) {\n \t\t\t\ttarget = xmalloc(serverlen + posn - i - 6);\n-\t\t\t\tstrlcpy(target, base, serverlen);\n-\t\t\t\tstrlcpy(target + serverlen, data + i, posn - i - 6);\n+\t\t\t\tmemcpy(target, base, serverlen);\n+\t\t\t\tmemcpy(target + serverlen, data + i,\n+\t\t\t\t       posn - i - 7);\n+\t\t\t\ttarget[serverlen + posn - i - 7] = 0;\n \t\t\t\tif (get_verbosely)\n \t\t\t\t\tfprintf(stderr,\n \t\t\t\t\t\t\"Also look at %s\\n\", target);\n"},{"id":"26782","messageId":"17671.23044.481280.965798@cargo.ozlabs.ibm.com","threadId":"5546","inReplyTo":"7v7j08eikw.fsf@assigned-by-dhcp.cox.net","subject":"Re: problem with http clone/pull","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2006-09-13T01:08:20Z","receivedAt":"2006-09-13T01:08:20Z","isPatch":false,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Junio C Hamano writes:\n\n> Perhaps this would fix it?\n\nYes, it works with that patch.  Thanks.\n\nPaul.\n"},{"id":"26818","messageId":"7v7j07a8sf.fsf@assigned-by-dhcp.cox.net","threadId":"5546","inReplyTo":"17671.23044.481280.965798@cargo.ozlabs.ibm.com","subject":"Re: problem with http clone/pull","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-13T19:03:28Z","receivedAt":"2006-09-13T19:03:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I'll do 1.4.2.1 with a fix for this and push it out hopefully\ntoday.\n"}]}