git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git: Wrong parsing of ssh urls with IPv6 literals ignores port

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Jun 12, 2012, 18:46 UTC
Message-ID
<4FD78EA0.2090306@lsrfire.ath.cx>
In-Reply-To
<20120610090516.GA30177@burratino>
Am 10.06.2012 11:05, schrieb Jonathan Nieder:
Show 17 quoted lines
> 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
Previous: Jonathan NiederNext: Jonathan Nieder
Message 2 of 9 in “Re: git: Wrong parsing of ssh urls with IPv6 literals ignores port”
  1. Jonathan NiederJun 10, 2012
  2. René ScharfeJun 12, 2012
  3. Jonathan NiederJun 12, 2012
  4. Jonathan NiederJun 12, 2012
  5. René ScharfeJun 13, 2012
  6. Junio C HamanoJun 13, 2012
  7. Jonathan NiederJun 13, 2012
  8. Junio C HamanoJun 13, 2012
  9. Jonathan NiederJun 13, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.