This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 163773 - ftp: connect: Invalid argument after kernel update
ftp: connect: Invalid argument after kernel update
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: ftp (Show other bugs)
3
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Petr Raszyk
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-07-20 18:10 EDT by Martin Burchell
Modified: 2007-11-30 17:11 EST (History)
4 users (show)

See Also:
Fixed In Version: 0.17 Rel. 27
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-08-22 11:17:02 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Martin Burchell 2005-07-20 18:10:42 EDT
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 08:04:19 EDT
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 07:25:46 EDT
ncftp works fine so I'm using that instead
Comment 3 Martin Burchell 2005-07-24 18:31:19 EDT
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 17:39:52 EDT
Also lftp works fine, I can download/upload files with it.
Comment 5 Dave Jones 2005-07-28 02:28:14 EDT
Nalin, this looks like an FC3 dupe of the devel bug at 158234
Comment 6 William Kucharski 2005-07-29 15:30:31 EDT
Same problem here, sftp also works just fine.
Comment 7 William Kucharski 2005-07-29 15:43:00 EDT
(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 11:15:31 EDT
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 15:23:48 EDT
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 07:41:03 EDT
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 17:53:54 EDT
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 04:26:00 EDT
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

Note You need to log in before you can comment on or make changes to this bug.