Bug 1847 - SFTP doen't work well with IPV6 address
Summary: SFTP doen't work well with IPV6 address
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp (show other bugs)
Version: 5.6p1
Hardware: All Linux
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_5_9
  Show dependency treegraph
 
Reported: 2010-12-22 15:51 AEDT by Adam
Modified: 2011-09-06 15:33 AEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam 2010-12-22 15:51:30 AEDT
Greetings.

I'm using ssh 5.6p1 release and have met a problem using SFTP with IPV6 address.  Here's a brief.

When I ran command "sftp -6 fe80::217:8ff:fe7c:d91c", SFTP threw out below error messages.

ssh: Could not resolve hostname fe80: host nor service provided, or not known
Connection closed


See that the hostname has been cut as "fe80", and of cource this could not be resolved.  By reading sftp.c, I noticed that this happened in line 2207.

2207         if ((cp = colon(host)) != NULL) {
2208             *cp++ = '\0';
2209             file1 = cp;
2210         }

The function colon(…) is used to analyze if user's input command is like “sftp host_address:/directory”.  If it is, colon(…) modifies the value of “host” from “host_address:/directory” to “host_address”, and returns value “/directory” to string “cp”.

In current case, I think colon(...) incorrectly cuts a valid IPV6 address.  
Would you please verify this bug and do a fix?  Thanks.
Comment 1 Adam 2010-12-22 16:52:13 AEDT
Since sftp allows users to use enter command like "sftp address:/directory", there could also be some problems when address is an IPV6 address.
Comment 2 Damien Miller 2011-05-06 11:09:27 AEST
You should enclose IPv6 addresses in square brackets to avoid ambiguity. E.g. sftp [::1]

I'll add a note to sftp.1:

+.Pp
+Since some usage formats use colon characters to delimit host names from path
+names, IPv6 addresses must be enclosed in square brackets to avoid ambiguity.
+.Pp
Comment 3 Damien Miller 2011-09-06 15:33:07 AEST
close resolved bugs now that openssh-5.9 has been released