Bug 163773

Summary: ftp: connect: Invalid argument after kernel update
Product: [Fedora] Fedora Reporter: Martin Burchell <martinburchell+bug>
Component: ftpAssignee: Petr Raszyk <praszyk>
Status: CLOSED CURRENTRELEASE QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: medium    
Version: 3CC: kucharsk, nalin, reg.bugs, wtogami
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: 0.17 Rel. 27 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-08-22 15:17:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Martin Burchell 2005-07-20 22:10:42 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Fedora/1.0.4-1.3.1 Firefox/1.0.4

Description of problem:
Since I installed the kernel update kernel-2.6.12-1.1372_FC3 I can connect to an ftp server but I get the error "ftp: connect: Invalid argument" if I try anything else

This happens on both FTP servers I've tried. If I reboot with kernel-2.6.11-1.35_FC3 ftp works fine as before.


Version-Release number of selected component (if applicable):
kernel-2.6.12-1.1372_FC3

How reproducible:
Always

Steps to Reproduce:
Connect to ftp site and try ls, get or put


Actual Results:  Get message:
ftp: connect: Invalid argument

Unable to list, download or upload files


Expected Results:  Should be able to list, download or upload files


Additional info:

ftp-0.17-22

This is just an example:

$ ftp foo.bar.com
Connected to foo.bar.com (...).
220-
220-##################################################################
220-
220- Welcome to foo.bar.com
220-
220-##################################################################
220-
220 foo.bar.com FTP server ready
331 Password required for spooky.
230 User spooky logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (...)
ftp: connect: Invalid argument

Comment 1 Vlado Potisk 2005-07-22 12:04:19 UTC
The same problem here. Output from strace:

connect(5, {sa_family=AF_INET, sin_port=htons(39625),
sin_addr=inet_addr("192.168.1.2")}, 28) = -1 EINVAL (Invalid argument)

Comment 2 Martin Burchell 2005-07-23 11:25:46 UTC
ncftp works fine so I'm using that instead


Comment 3 Martin Burchell 2005-07-24 22:31:19 UTC
I just upgraded to FC4, including the latest updates and ftp appears to work OK

kernel-2.6.12-1.1398_FC4
ftp-0.17-26


Comment 4 Vlado Potisk 2005-07-27 21:39:52 UTC
Also lftp works fine, I can download/upload files with it.

Comment 5 Dave Jones 2005-07-28 06:28:14 UTC
Nalin, this looks like an FC3 dupe of the devel bug at 158234


Comment 6 William Kucharski 2005-07-29 19:30:31 UTC
Same problem here, sftp also works just fine.

Comment 7 William Kucharski 2005-07-29 19:43:00 UTC
(In reply to comment #6)
> Same problem here, sftp also works just fine.

Confirmed that ftp-0.17-26 fixes the problem, so this does indeed look to be a
dup of 158234.

Comment 8 Petr Raszyk 2005-08-22 15:15:31 UTC
The patch (bug #158234) does instead of:
                       printf ("%ld\n", my_long);
                only this:
                       printf ("%ld\n", (long)my_long);
A cosmetic thing (user info). Back to your issue. 
In your case/example a 'connect' fails. A function from socket-library
(library outside ftp-client). In your case this function returns error-code
(error-code == errno == EINVAL == Invalid argument). 
This indicates a wrong parametr-value to function 'connect()'.
Here is a posix-man-page:

EINVAL The address_len argument is not a valid length for  the  address
      family; or invalid address family in the sockaddr structure.


I have inserted 'trace' in ftp source (ftp ftp-0.17-26, FEDORA CORE 4)
and here is output:


PID=10714: ftp.PRO: ftp.c: initconn(): 1717: errno=0:  connect OK: su_family=AF_INTE
PID=10714: ftp.PRO: ftp.c: initconn(): 1720: errno=0:  connect OK: sizeof
(su_sin6)=>28<
PID=10714: ftp.PRO: ftp.c: initconn(): 1721: errno=0:  connect OK: .su_port=>56805<

The same values as in your case (note: port can be different). This 'bug'
can not be reproduced on FEDORA CORE 4.
It is possible, that the kernel-2.6.12-1.1372_FC3 udate was wrong.

Comment 9 Nalin Dahyabhai 2005-08-22 19:23:48 UTC
Petr, if it's an AF_INET socket, the size of the socket address should be
sizeof(struct sockaddr_in), not sizeof(struct sockaddr_in6), but ftp was always
passing the size of a union of the two, which is larger.  The kernel didn't
return an error before, but it's a bug in the FTP client to assume that it wouldn't.

Comment 10 Petr Raszyk 2005-08-23 11:41:03 UTC
Nalin, my 'trace' was not precise. The 'connect()' call in the file ftp.c,
in the function initconn(): 
(initconn() will be called by "ls" ftp-command)


if (connect(data, (struct sockaddr *) &data_addr,
      (data_addr.su_family == AF_INET ?
      sizeof(data_addr.su_sin) :
      sizeof(data_addr.su_sin6)))<0 )
        {
           perror ("ftp: connect");
           return (1);
        }

If we have AF_INET, third parameter to connect() is sizeof (.su_sin).
If we have AF_INET6, third parameter to connect() is sizeof (.su_sin6).
NOTE: second case must be AF_INET6: In the function hook() is macro used
#define ex_af2prot(a) (a == AF_INET ? 1 : (a == AF_INET6 ? 2 : 0))

Comment 11 Nalin Dahyabhai 2005-08-23 21:53:54 UTC
Petr, it's tricky.  The code you list is the correct code, but that's not what's
in the version of the ftp package we have on FC3.

Comment 12 Petr Raszyk 2005-08-24 08:26:00 UTC
Nalin, you are right. An old patch (netkit-ftp.usagi-ipv6.patch) helps.
You can:
         Install FEDORA CORE 4
               or
         Install (current) ftp-client 0.17 (Release 27)

It works on FEDORA CORE 4, FEDORA CORE 3 (at least).

Petr Raszyk