Hi,

After download 3.6.1 and compile,I find that lftp reports wrong ip
address number.If the ftp server has n ip(s),lftp reports 3*n addresses
found.

lftp :~> open 127.0.0.1
---- Resolving host address...
---- 3 addresses found
lftp 127.0.0.1:~> ls
---- Connecting to 127.0.0.1 (127.0.0.1) port 21
**** Socket error (Connection refused) - reconnecting
---- Connecting to 127.0.0.1 (127.0.0.1) port 21
**** Socket error (Connection refused) - reconnecting
---- Connecting to 127.0.0.1 (127.0.0.1) port 21
**** Socket error (Connection refused) - reconnecting
Interrupt                                  
lftp 127.0.0.1:~> open download.fedora.redhat.com
---- Resolving host address...
---- 6 addresses found                                         
lftp download.fedora.redhat.com:~>

Sometimes I may be banned because I connect to the server 3 times with
no interval.In Resolver.cc:685,getaddrinfo() get 3 same addresses of
"127.0.0.1" with different ai_socktype and ai_protocol,then the 3 same
"127.0.0.1" are all added by AddAddress() in Resolver.cc:714.

# LC_ALL=c gdb --args ./lftp 127.0.0.1
GNU gdb Red Hat Linux (6.6-42.fc8rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i386-redhat-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) set follow-fork-mode child 
(gdb) br Resolver.cc:685
Breakpoint 1 at 0x80f5edb: file Resolver.cc, line 685.
(gdb) r
Starting program: /root/361/bin/lftp 127.0.0.1
---- Resolving host address...
[Switching to process 3079]

Breakpoint 1, Resolver::LookupOne (this=0x8c034a0, 
    name=0x8c029b0 "127.0.0.1") at Resolver.cc:685
685           ainfo_res = getaddrinfo(name, NULL, &a_hint, &ainfo);
(gdb) p ainfo
$1 = (addrinfo *) 0x0
(gdb) n
687           if(ainfo_res == 0)
(gdb) p *ainfo
$2 = {ai_flags = 1, ai_family = 2, ai_socktype = 1, 
  ai_protocol = 6, ai_addrlen = 16, ai_addr = 0x8c01850, 
  ai_canonname = 0x0, ai_next = 0x8c01868}
(gdb) p/x *ainfo.ai_addr
$3 = {sa_family = 0x2, sa_data = {0x0, 0x0, 0x7f, 0x0, 0x0, 0x1, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
(gdb) p *ainfo.ai_next
$4 = {ai_flags = 1, ai_family = 2, ai_socktype = 2, 
  ai_protocol = 17, ai_addrlen = 16, ai_addr = 0x8c01888, 
  ai_canonname = 0x0, ai_next = 0x8c018a0}
(gdb) p/x *ainfo.ai_next.ai_addr
$5 = {sa_family = 0x2, sa_data = {0x0, 0x0, 0x7f, 0x0, 0x0, 0x1, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
(gdb) p *ainfo.ai_next.ai_next
$6 = {ai_flags = 1, ai_family = 2, ai_socktype = 3, 
  ai_protocol = 0, ai_addrlen = 16, ai_addr = 0x8c018c0, 
  ai_canonname = 0x0, ai_next = 0x0}
(gdb) p/x *ainfo.ai_next.ai_next.ai_addr
$7 = {sa_family = 0x2, sa_data = {0x0, 0x0, 0x7f, 0x0, 0x0, 0x1, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
(gdb)

In lftp ai_socktype is not set,but in wget 1.11 ai_socktype is set to be
SOCK_STREAM in host.c:724.

724     hints.ai_socktype = SOCK_STREAM;

If in Resolver::LookupOne() ai_socktype is set to be SOCK_STREAM before
getaddrinfo(),then getaddrinfo() get only 1 address of "127.0.0.1".

(gdb) p *ainfo
$2 = {ai_flags = 1, ai_family = 2, ai_socktype = 1, 
  ai_protocol = 6, ai_addrlen = 16, ai_addr = 0x84bdf48, 
  ai_canonname = 0x0, ai_next = 0x0}
(gdb) p/x *ainfo.ai_addr
$3 = {sa_family = 0x2, sa_data = {0x0, 0x0, 0x7f, 0x0, 0x0, 0x1, 
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}



Reply via email to