summaryrefslogtreecommitdiff
path: root/plugins/loopback.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-07-16 02:43:47 +0200
committerMarcel Holtmann <marcel@holtmann.org>2009-07-16 02:43:47 +0200
commite6be58c2322fab098466d66816d99f67ae5a210f (patch)
tree0d312815c73b5e61c2ea0a75dda84000a8809c5c /plugins/loopback.c
parent016c1490e180fa737815bf65f96cc60b1761ed89 (diff)
downloadconnman-e6be58c2322fab098466d66816d99f67ae5a210f.tar.gz
connman-e6be58c2322fab098466d66816d99f67ae5a210f.tar.bz2
connman-e6be58c2322fab098466d66816d99f67ae5a210f.zip
Fix handling of strict-aliasing rules
Diffstat (limited to 'plugins/loopback.c')
-rw-r--r--plugins/loopback.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/plugins/loopback.c b/plugins/loopback.c
index 782853ef..59716c24 100644
--- a/plugins/loopback.c
+++ b/plugins/loopback.c
@@ -176,7 +176,7 @@ static int setup_hostname(void)
static int setup_loopback(void)
{
struct ifreq ifr;
- struct sockaddr_in *addr;
+ struct sockaddr_in addr;
int sk, err;
sk = socket(PF_INET, SOCK_DGRAM, 0);
@@ -197,9 +197,10 @@ static int setup_loopback(void)
goto done;
}
- addr = (struct sockaddr_in *) &ifr.ifr_addr;
- addr->sin_family = AF_INET;
- addr->sin_addr.s_addr = inet_addr("127.0.0.1");
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+ memcpy(&ifr.ifr_addr, &addr, sizeof(ifr.ifr_addr));
err = ioctl(sk, SIOCSIFADDR, &ifr);
if (err < 0) {
@@ -208,9 +209,10 @@ static int setup_loopback(void)
goto done;
}
- addr = (struct sockaddr_in *) &ifr.ifr_netmask;
- addr->sin_family = AF_INET;
- addr->sin_addr.s_addr = inet_addr("255.0.0.0");
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = inet_addr("255.0.0.0");
+ memcpy(&ifr.ifr_netmask, &addr, sizeof(ifr.ifr_netmask));
err = ioctl(sk, SIOCSIFNETMASK, &ifr);
if (err < 0) {