All of lore.kernel.org
 help / color / mirror / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "Eduardo Trápani" <etrapani@gmail.com>,
	git@vger.kernel.org,
	"YOSHIFUJI Hideaki" <yoshfuji@linux-ipv6.org>
Subject: Re: git: Wrong parsing of ssh urls with IPv6 literals ignores port
Date: Tue, 12 Jun 2012 20:46:56 +0200	[thread overview]
Message-ID: <4FD78EA0.2090306@lsrfire.ath.cx> (raw)
In-Reply-To: <20120610090516.GA30177@burratino>

Am 10.06.2012 11:05, schrieb Jonathan Nieder:
> Hi Eduardo,
> 
> Eduardo Trápani wrote[1]:
> 
>> git clone ssh://[2001:0:53aa:64c:1845:430c:4179:d71f]:3333/deponejo/unua
>>
>> Will try to connect to port 22 and not 3333.  The port number seems to be
>> ignored.
> 
> True.  How about something like this (untested)?
> 
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> [1] http://bugs.debian.org/646178
> 
>   connect.c |   14 +++++++++++---
>   1 file changed, 11 insertions(+), 3 deletions(-)

How about this instead?  Except perhaps with a commit message that is vaguely
understandable?

-- >8 --
If we encounter an address part shaped like "[HOST]:PORT", we skip the opening
bracket and replace the closing one with a NUL.  The variable host then points
to HOST and we've cut off the PORT part.  Thus, when we go looking for it using
host a bit later, we can't find it.  Start at end instead, which either points
to the colon, if present, or is equal to host.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
We have similar code in daemon.c.  Can we share more?  And make it testable?

 connect.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/connect.c b/connect.c
index 912cdde..41b7400 100644
--- a/connect.c
+++ b/connect.c
@@ -536,7 +536,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 	 * Add support for ssh port: ssh://host.xy:<port>/...
 	 */
 	if (protocol == PROTO_SSH && host != url)
-		port = get_port(host);
+		port = get_port(end);
 
 	if (protocol == PROTO_GIT) {
 		/* These underlying connection commands die() if they
-- 
1.7.10.2

  reply	other threads:[~2012-06-12 18:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20111022001704.3115.87464.reportbug@hejmo>
2012-06-10  9:05 ` git: Wrong parsing of ssh urls with IPv6 literals ignores port Jonathan Nieder
2012-06-12 18:46   ` René Scharfe [this message]
2012-06-12 20:29     ` Jonathan Nieder
2012-06-12 21:00       ` Jonathan Nieder
2012-06-13 16:33         ` René Scharfe
2012-06-13 17:21           ` Junio C Hamano
2012-06-13 19:43             ` Jonathan Nieder
2012-06-13 20:10               ` Junio C Hamano
2012-06-13 20:39                 ` Jonathan Nieder

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=4FD78EA0.2090306@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=etrapani@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=yoshfuji@linux-ipv6.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.