Re: [PATCH] socket_local46: Make room on the stack for IPv6 sockaddrs

From: Jesse Young <jlyo_at_jlyo.org>
Date: Sun, 26 Jul 2015 15:11:32 -0500

On Sun, 26 Jul 2015 21:29:31 +0200
Laurent Bercot <ska-skaware_at_skarnet.org> wrote:

> On 26/07/2015 21:15, Jesse Young wrote:
> > byte_copy() reads past the end of the sockaddr structure because it
> > isn't sufficiently large enough to handle sockaddr_in6 addresses
> > resulting in undefined behavior. armv6-alpine-linux-muslgnueabihf-gcc
> > 5.1.0-r0 generates the "UDF" instruction in this case, causing programs
> > to SIGILL.
>
> Ah, good catch. sockaddr used to work, but it's stricto sensu incorrect -
> and musl is very touchy with standards.
> I believe the right fix is to use sockaddr_storage, though. I'll commit
> a fix tomorrow.
> Thanks !
>

I don't think sockaddr_storage is strictly necessary in this instance.
getsockname() will truncate its result, but socket_local46() won't
use that result unless sa_family is AF_INET or AF_INET6. That being
said, the only penalty to using sockaddr_storage is the extra space, and
it'd be more robust in cases of buggy implementations of getsockname().

Jesse
Received on Sun Jul 26 2015 - 20:11:32 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC