[PATCH] Fix strict-aliasing warning in resolv/res_hconf.c
Florian Weimer
fweimer@redhat.com
Wed May 20 14:10:00 GMT 2015
On 05/20/2015 10:23 AM, Andreas Schwab wrote:
> Florian Weimer <fweimer@redhat.com> writes:
>
>> Looking at struct ifreq, it is rather mysterious to me how this is
>> supposed to work at all. I mean, struct sockaddr has just 14 bytes
>> storage for address information, but IPv6 addresses need 16 bytes, and
>> socket addresses contain even more information than a raw address.
>
> This ioctl is only defined for IPv4.
Oh, but then we can add a union member of the appropriate type (just one
is needed):
diff --git a/sysdeps/gnu/net/if.h b/sysdeps/gnu/net/if.h
index 49a048c..39f40de 100644
--- a/sysdeps/gnu/net/if.h
+++ b/sysdeps/gnu/net/if.h
@@ -24,6 +24,7 @@
#ifdef __USE_MISC
# include <sys/types.h>
# include <sys/socket.h>
+# include <netinet/in.h>
#endif
@@ -139,6 +140,7 @@ struct ifreq
struct sockaddr ifru_broadaddr;
struct sockaddr ifru_netmask;
struct sockaddr ifru_hwaddr;
+ struct sockaddr_in ifru_addr_in;
short int ifru_flags;
int ifru_ivalue;
int ifru_mtu;
This doesn't change ABI. And then the code in resolv/res_hconf.c could
use that new member, without any casts.
--
Florian Weimer / Red Hat Product Security
More information about the Libc-alpha
mailing list