cURL / Mailing Lists / curl-library / Single Mail

curl-library

some problems with getsockname in ftp and others

From: Peter Sylvester <Peter.Sylvester_at_edelweb.fr>
Date: Wed, 06 Sep 2006 16:22:37 +0200

Enclosed please find a patch for lib/ftp.c that addresses some problems
that I see
with getsockname sockkaddr_in etc. I will try to result shortly what
happens currently using an example from the existing code.

     if(0 == getsockname(sock, (struct sockaddr *) &add, &size)) {
       s=accept(sock, (struct sockaddr *) &add, &size);

Besides the fact that the getsockname is not necssary (but could be
useful in a debugging mode, the code seems dangerous to me:

The field 'add' has a length n, size is initilized with that value before.
After the call to getsockname the size value may be shorter but also
longer. The current approach in curl is that 'add' has a some 'very'
long size. But in any case the value of size in the above code snippet
should be reinitialized to the sizeof(add).

The patch changes several places in the code. It also tries to
harmonize a bit the error messages.

At least at one plce in tftp there is a related problem where
a memcpy is done with an 'unsafe' size.

Any comments are welcome.

regards
Peter

-- 
To verify the signature, see http://edelpki.edelweb.fr/ 
Cela vous permet de charger le certificat de l'autorité; 
die Liste mit zurückgerufenen Zertifikaten finden Sie da auch. 

Received on 2006-09-06