[Bug 2956] New: using "sftp root@[2001::16%eth0]", output error: Could not resolve hostname: Name or service not known

bugzilla-daemon at bugzilla.mindrot.org bugzilla-daemon at bugzilla.mindrot.org
Tue Jan 22 18:13:53 AEDT 2019


https://bugzilla.mindrot.org/show_bug.cgi?id=2956

            Bug ID: 2956
           Summary: using "sftp root@[2001::16%eth0]", output error: Could
                    not resolve hostname: Name or service not known
           Product: Portable OpenSSH
           Version: 7.9p1
          Hardware: ix86
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: sftp
          Assignee: unassigned-bugs at mindrot.org
          Reporter: xuchunmei at huawei.com

when using sftp to connect ipv6 address without path, error happens
like this:
sftp root@[2001::16%eth0]

ssh: Could not resolve hostname [2001::16%eth0]: Name
or service not known
Connection closed.
Connection closed

openssh version is:
openssh-clients-7.8p1-3.fc29.x86_64
OS is fedora29 x86

i try to analyse the error output,
when parse_user_host_path, colon funciton:
char *
colon(char *cp)
{
        int flag = 0;

        if (*cp == ':')         /* Leading colon is part of file name.
*/
                return NULL;
        if (*cp == '[')
                flag = 1;

        for (; *cp; ++cp) {
                if (*cp == '@' && *(cp+1) == '[')
                        flag = 1;
                if (*cp == ']' && *(cp+1) == ':' && flag)
                        return (cp+1);
                if (*cp == ':' && !flag)
                        return (cp);
                if (*cp == '/')
                        return NULL;
        }
        return NULL;
}

after ']' there must be ':', otherwise return NULL, then the whole arg
"root@[2001::16%eth0]" be treated as a plain hostname, host 
resolv failed.

here is my solution:
---
 misc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/misc.c b/misc.c
index bdc06fd..84dc451 100644
--- a/misc.c
+++ b/misc.c
@@ -557,6 +557,8 @@ colon(char *cp)
            flag = 1;
        if (*cp == ']' && *(cp+1) == ':' && flag)
            return (cp+1);
+       if (*cp == ']' && *(cp+1) == '\0' && flag)
+           return (cp+1);
        if (*cp == ':' && !flag)
            return (cp);
        if (*cp == '/')
-- 

please check.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list