Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- There's no need to reinvent the wheel here; RtlIpv4AddressToStringA avoids the need for strcpy and is guaranteed to do nothing if the pointer to the output string is null. --- dlls/iphlpapi/ifenum.c | 20 -------------------- dlls/iphlpapi/ifenum.h | 5 ----- dlls/iphlpapi/iphlpapi_main.c | 14 +++++++------- 3 files changed, 7 insertions(+), 32 deletions(-)
diff --git a/dlls/iphlpapi/ifenum.c b/dlls/iphlpapi/ifenum.c index c3abdf0e536..288e04db7b8 100644 --- a/dlls/iphlpapi/ifenum.c +++ b/dlls/iphlpapi/ifenum.c @@ -35,14 +35,6 @@ #include <sys/socket.h> #endif
-#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif - -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif - #ifdef HAVE_NET_IF_H #include <net/if.h> #endif @@ -1106,15 +1098,3 @@ ULONG v6addressesFromIndex(IF_INDEX index, SOCKET_ADDRESS **addrs, ULONG *num_ad }
#endif - -char *toIPAddressString(unsigned int addr, char string[16]) -{ - if (string) { - struct in_addr iAddr; - - iAddr.s_addr = addr; - /* extra-anal, just to make auditors happy */ - lstrcpynA(string, inet_ntoa(iAddr), 16); - } - return string; -} diff --git a/dlls/iphlpapi/ifenum.h b/dlls/iphlpapi/ifenum.h index c6bf9575759..558dff64cb6 100644 --- a/dlls/iphlpapi/ifenum.h +++ b/dlls/iphlpapi/ifenum.h @@ -109,11 +109,6 @@ DWORD getIPAddrTable(PMIB_IPADDRTABLE *ppIpAddrTable, HANDLE heap, DWORD flags) ULONG v6addressesFromIndex(IF_INDEX index, SOCKET_ADDRESS **addrs, ULONG *num_addrs, SOCKET_ADDRESS **masks) DECLSPEC_HIDDEN;
-/* Converts the network-order bytes in addr to a printable string. Returns - * string. - */ -char *toIPAddressString(unsigned int addr, char string[16]) DECLSPEC_HIDDEN; - DWORD getInterfaceMtuByName(const char *name, PDWORD mtu) DECLSPEC_HIDDEN; DWORD getInterfaceStatusByName(const char *name, INTERNAL_IF_OPER_STATUS *status) DECLSPEC_HIDDEN;
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index bd1fea02e19..09414d26dde 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -717,18 +717,18 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen) for (i = 0; i < ipAddrTable->dwNumEntries; i++) { if (ipAddrTable->table[i].dwIndex == ptr->Index) { if (firstIPAddr) { - toIPAddressString(ipAddrTable->table[i].dwAddr, + RtlIpv4AddressToStringA((IN_ADDR *)&ipAddrTable->table[i].dwAddr, ptr->IpAddressList.IpAddress.String); - toIPAddressString(ipAddrTable->table[i].dwMask, + RtlIpv4AddressToStringA((IN_ADDR *)&ipAddrTable->table[i].dwMask, ptr->IpAddressList.IpMask.String); firstIPAddr = FALSE; } else { currentIPAddr->Next = nextIPAddr; currentIPAddr = nextIPAddr; - toIPAddressString(ipAddrTable->table[i].dwAddr, + RtlIpv4AddressToStringA((IN_ADDR *)&ipAddrTable->table[i].dwAddr, currentIPAddr->IpAddress.String); - toIPAddressString(ipAddrTable->table[i].dwMask, + RtlIpv4AddressToStringA((IN_ADDR *)&ipAddrTable->table[i].dwMask, currentIPAddr->IpMask.String); nextIPAddr++; } @@ -749,9 +749,9 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen) && routeTable->table[i].u1.ForwardType == MIB_IPROUTE_TYPE_INDIRECT) { - toIPAddressString(routeTable->table[i].dwForwardNextHop, + RtlIpv4AddressToStringA((IN_ADDR *)&routeTable->table[i].dwForwardNextHop, ptr->GatewayList.IpAddress.String); - toIPAddressString(routeTable->table[i].dwForwardMask, + RtlIpv4AddressToStringA((IN_ADDR *)&routeTable->table[i].dwForwardMask, ptr->GatewayList.IpMask.String); } if (winsEnabled) { @@ -2224,7 +2224,7 @@ static DWORD get_dns_server_list(PIP_ADDR_STRING list, get_dns_servers( addr, num, TRUE );
for (i = 0, ptr = list; i < num; i++, ptr = ptr->Next) { - toIPAddressString(((struct sockaddr_in *)(addr + i))->sin_addr.s_addr, + RtlIpv4AddressToStringA((IN_ADDR *)&((struct sockaddr_in *)(addr + i))->sin_addr.s_addr, ptr->IpAddress.String); if (i == num - 1) ptr->Next = NULL;