Commit 4f36cae4 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

Avoid using the obsolete inet_addr.

parent 6d94aa47
...@@ -3815,7 +3815,7 @@ INT WINAPI WSAStringToAddressA(LPSTR AddressString, ...@@ -3815,7 +3815,7 @@ INT WINAPI WSAStringToAddressA(LPSTR AddressString,
LPINT lpAddressLength) LPINT lpAddressLength)
{ {
INT res=0; INT res=0;
LONG inetaddr; struct in_addr inetaddr;
LPSTR workBuffer=NULL,ptrPort; LPSTR workBuffer=NULL,ptrPort;
TRACE( "(%s, %x, %p, %p, %p)\n", AddressString, AddressFamily, lpProtocolInfo, TRACE( "(%s, %x, %p, %p, %p)\n", AddressString, AddressFamily, lpProtocolInfo,
...@@ -3853,10 +3853,9 @@ INT WINAPI WSAStringToAddressA(LPSTR AddressString, ...@@ -3853,10 +3853,9 @@ INT WINAPI WSAStringToAddressA(LPSTR AddressString,
} }
else else
((LPSOCKADDR_IN)lpAddress)->sin_port = 0; ((LPSOCKADDR_IN)lpAddress)->sin_port = 0;
inetaddr = inet_addr(workBuffer); if (inet_aton(workBuffer, &inetaddr) > 0)
if (inetaddr != INADDR_NONE)
{ {
((LPSOCKADDR_IN)lpAddress)->sin_addr.WS_s_addr = inetaddr; ((LPSOCKADDR_IN)lpAddress)->sin_addr.WS_s_addr = inetaddr.s_addr;
res = 0; res = 0;
} }
else else
......
...@@ -1210,9 +1210,12 @@ static void test_WSAStringToAddressA(void) ...@@ -1210,9 +1210,12 @@ static void test_WSAStringToAddressA(void)
"WSAStringToAddressA() failed unexpectedly: %d\n", WSAGetLastError() ); "WSAStringToAddressA() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr); len = sizeof(sockaddr);
sockaddr.sin_port = 0;
sockaddr.sin_addr.s_addr = 0;
ret = WSAStringToAddressA( address3, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len ); ret = WSAStringToAddressA( address3, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len );
ok( ret, "WSAStringToAddressA() succeeded unexpectedly: %d\n", WSAGetLastError() ); ok( !ret && sockaddr.sin_addr.s_addr == 0xffffffff,
"WSAStringToAddressA() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr); len = sizeof(sockaddr);
sockaddr.sin_port = 0; sockaddr.sin_port = 0;
...@@ -1223,9 +1226,12 @@ static void test_WSAStringToAddressA(void) ...@@ -1223,9 +1226,12 @@ static void test_WSAStringToAddressA(void)
"WSAStringToAddressA() failed unexpectedly: %d\n", WSAGetLastError() ); "WSAStringToAddressA() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr); len = sizeof(sockaddr);
sockaddr.sin_port = 0;
sockaddr.sin_addr.s_addr = 0;
ret = WSAStringToAddressA( address5, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len ); ret = WSAStringToAddressA( address5, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len );
ok( ret, "WSAStringToAddressA() succeeded unexpectedly: %d\n", WSAGetLastError() ); ok( !ret && sockaddr.sin_addr.s_addr == 0xffffffff && sockaddr.sin_port == 0xffff,
"WSAStringToAddressA() failed unexpectedly: %d\n", WSAGetLastError() );
} }
static void test_WSAStringToAddressW(void) static void test_WSAStringToAddressW(void)
...@@ -1257,7 +1263,6 @@ static void test_WSAStringToAddressW(void) ...@@ -1257,7 +1263,6 @@ static void test_WSAStringToAddressW(void)
"WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() ); "WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr); len = sizeof(sockaddr);
sockaddr.sin_port = 0; sockaddr.sin_port = 0;
sockaddr.sin_addr.s_addr = 0; sockaddr.sin_addr.s_addr = 0;
...@@ -1266,9 +1271,12 @@ static void test_WSAStringToAddressW(void) ...@@ -1266,9 +1271,12 @@ static void test_WSAStringToAddressW(void)
"WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() ); "WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr); len = sizeof(sockaddr);
sockaddr.sin_port = 0;
sockaddr.sin_addr.s_addr = 0;
ret = WSAStringToAddressW( address3, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len ); ret = WSAStringToAddressW( address3, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len );
ok( ret, "WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() ); ok( !ret && sockaddr.sin_addr.s_addr == 0xffffffff,
"WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr); len = sizeof(sockaddr);
sockaddr.sin_port = 0; sockaddr.sin_port = 0;
...@@ -1279,9 +1287,12 @@ static void test_WSAStringToAddressW(void) ...@@ -1279,9 +1287,12 @@ static void test_WSAStringToAddressW(void)
"WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() ); "WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() );
len = sizeof(sockaddr); len = sizeof(sockaddr);
sockaddr.sin_port = 0;
sockaddr.sin_addr.s_addr = 0;
ret = WSAStringToAddressW( address5, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len ); ret = WSAStringToAddressW( address5, AF_INET, NULL, (SOCKADDR*)&sockaddr, &len );
ok( ret, "WSAStringToAddressW() succeeded unexpectedly: %d\n", WSAGetLastError() ); ok( !ret && sockaddr.sin_addr.s_addr == 0xffffffff && sockaddr.sin_port == 0xffff,
"WSAStringToAddressW() failed unexpectedly: %d\n", WSAGetLastError() );
} }
/**************** Main program ***************/ /**************** Main program ***************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment