This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Is this an incorrect Qualcomm usage or a glibc bug?
- From: Florian Weimer <fweimer at redhat dot com>
- To: honan li <sayibobo at gmail dot com>
- Cc: libc-help at sourceware dot org
- Date: Fri, 1 Sep 2017 12:19:23 +0200
- Subject: Re: Is this an incorrect Qualcomm usage or a glibc bug?
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=fweimer at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8A3312DD83
- References: <CA+xL5a_qD-Pca+_86UPQV2OTdy03UqVD6h=rXVmqbjS73m5TSQ@mail.gmail.com> <21f4fedb-3c5c-260e-1c67-a632b6859e2b@redhat.com> <CA+xL5a8gXSzZE4CpugDnXiYu1WfuOKiJKpQY8HW0WtRGXG2wJQ@mail.gmail.com>
On 09/01/2017 12:07 PM, honan li wrote:
> define SASTORAGE_DATA(addr) (addr).__ss_padding
>
> typedef struct qcmap_cm_nl_prefix_info_s {
> boolean prefix_info_valid;
> unsigned char prefix_len;
> unsigned int mtu;
> struct sockaddr_storage prefix_addr;
> struct ifa_cacheinfo cache_info;
> } qcmap_cm_nl_prefix_info_t;
>
> void QCMAP_Backhaul::GetIPV6PrefixInfo(char *devname,
> qcmap_cm_nl_prefix_info_t
> *ipv6_prefix_info)
> {
> struct sockaddr_in6 *sin6 = NULL;
>
> ...
>
> sin6 = (struct sockaddr_in6 *)&ipv6_prefix_info->prefix_addr;
> memcpy(SASTORAGE_DATA(ipv6_prefix_info->prefix_addr),
> RTA_DATA(rta),
> sizeof(sin6->sin6_addr));
> ...
> }
Currently publicly available here:
https://github.com/Bigcountry907/HTC_a13_vzw_Kernel/blob/master/vendor/qcom/proprietary/data/mobileap_v2/server/src/QCMAP_ConnectionManager.cpp#L3658
I would expect applications do something like this instead:
struct sockaddr_in6 sin6;
memset (&sin6, 0, sizeof (sin6));
sin6.sin6_family = AF_INET6;
memcpy (&sin6.sin6_addr, RTA_DATA (rta), sizeof (sin6.sin6_addr));
memcpy (&ipv6_prefix_info->prefix_addr, &sin6, sizeof (sin6));
This avoids any aliasing issues and a dependency on the internals of
struct sockaddr_storage (which is only intended as a way to allocate a
generic struct sockaddr of sufficient size and alignment). It also
initializes the other components of the socket address (such as the port
number and flow label).
Thanks,
Florian