diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-10-17 16:53:15 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-10-17 16:53:15 -0600 |
commit | 34d57dd1c177992829307c92cab91bd8118ee1dd (patch) | |
tree | 2eb5deb6d03d4eefed8fde8c13e6356fdefc82ec /apps/netutils | |
parent | 51640da0fe8554bec2624f6b4d10bcfb56683724 (diff) | |
download | nuttx-34d57dd1c177992829307c92cab91bd8118ee1dd.tar.gz nuttx-34d57dd1c177992829307c92cab91bd8118ee1dd.tar.bz2 nuttx-34d57dd1c177992829307c92cab91bd8118ee1dd.zip |
Fix memcpy of host address in netlib_gethostaddr(). From Brennan Ashton
Diffstat (limited to 'apps/netutils')
-rw-r--r-- | apps/netutils/netlib/netlib_gethostaddr.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/netutils/netlib/netlib_gethostaddr.c b/apps/netutils/netlib/netlib_gethostaddr.c index b772b1ee4..ec6659041 100644 --- a/apps/netutils/netlib/netlib_gethostaddr.c +++ b/apps/netutils/netlib/netlib_gethostaddr.c @@ -71,7 +71,7 @@ * ipaddr The location to return the IP address * * Return: - * 0 on sucess; -1 on failure + * 0 on success; -1 on failure * ****************************************************************************/ @@ -93,14 +93,20 @@ int netlib_gethostaddr(const char *ifname, struct in_addr *addr) if (!ret) { #ifdef CONFIG_NET_IPv6 - memcpy(addr, &req.ifr_addr, sizeof(struct in6_addr)); + FAR struct sockaddr_in6 *req_addr; + req_addr = (FAR struct sockaddr_in6 *)&req.ifr_addr; + memcpy(addr, &req_addr->sin6_addr, sizeof(struct in6_addr)); #else - memcpy(addr, &req.ifr_addr, sizeof(struct in_addr)); + FAR struct sockaddr_in *req_addr; + req_addr = (struct sockaddr_in*)&req.ifr_addr; + memcpy(addr, &req_addr->sin_addr, sizeof(struct in_addr)); #endif } + close(sockfd); } } + return ret; } |