[PATCH] Incorrect addrlen when calling connect

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Incorrect addrlen when calling connect

dtbartle
Hi,

In resolv/res_send.c, connect may be passed a 'struct sockaddr_in'
although the addrlen will always be sizeof(struct sockaddr_in6). The
attached patch fixes this by setting the addrlen according to
nsap->sin6_family, as done elsewhere in this file already.

-- David

glibc-res_send-connect.diff (734 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Incorrect addrlen when calling connect

Ulrich Drepper
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Bartley wrote:
> In resolv/res_send.c, connect may be passed a 'struct sockaddr_in'
> although the addrlen will always be sizeof(struct sockaddr_in6).

This shouldn't be a problem.  In what situation do you see a problem?

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkhfzvsACgkQ2ijCOnn/RHSZ5QCfUnyCSx9sW11NsEDDRLeIuCUL
apcAn2KuG2xmC4YCaxX4R919Nq/CKYBr
=y9sp
-----END PGP SIGNATURE-----
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Incorrect addrlen when calling connect

dtbartle
On Mon, Jun 23, 2008 at 12:27 PM, Ulrich Drepper <[hidden email]> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> David Bartley wrote:
>> In resolv/res_send.c, connect may be passed a 'struct sockaddr_in'
>> although the addrlen will always be sizeof(struct sockaddr_in6).
>
> This shouldn't be a problem.  In what situation do you see a problem?

This is an issue on Solaris, which I'm aware is not a supported
platform. This patch would improve portability without any drawbacks
that I can see.

-- David

>
> - --
> ➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkhfzvsACgkQ2ijCOnn/RHSZ5QCfUnyCSx9sW11NsEDDRLeIuCUL
> apcAn2KuG2xmC4YCaxX4R919Nq/CKYBr
> =y9sp
> -----END PGP SIGNATURE-----
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Incorrect addrlen when calling connect

Ulrich Drepper
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Bartley wrote:
> This is an issue on Solaris, which I'm aware is not a supported
> platform. This patch would improve portability without any drawbacks
> that I can see.

The reason it's not done is that it unnecessarily increases code size
and makes the program slower.  So, it's not no-impact.

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkhh43YACgkQ2ijCOnn/RHQciwCgzoiyKxKtyRM4dNQbcxrebdHx
NTwAnRwWvKzFuwfcABQuBT+7SVt+m5Q6
=uRpK
-----END PGP SIGNATURE-----
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Incorrect addrlen when calling connect

dtbartle
On Wed, Jun 25, 2008 at 2:19 AM, Ulrich Drepper <[hidden email]> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> David Bartley wrote:
>> This is an issue on Solaris, which I'm aware is not a supported
>> platform. This patch would improve portability without any drawbacks
>> that I can see.
>
> The reason it's not done is that it unnecessarily increases code size
> and makes the program slower.  So, it's not no-impact.

The call to connect would far outweigh any cost imposed by a simple
comparison and assignment that this patch would add. If you are really
worried about code size, you should cut down some of the error
strings; I reckon that replacing all instances of the string 'garbage'
with 'junk' would save more memory than this patch would take.

If this code is so troublesome, why is this same code used elsewhere
in res_send.c?

-- David