wininet: Fix InternetGetConnectedStateEx[A|W]
Bruno Jesus
00cpxxx at gmail.com
Wed Feb 5 17:39:19 CST 2014
Ensure the function always returns true in any case and cope with
LoadStringW doing special stuff when buffer size is zero or 1 (not
closing the string).
Fixes http://bugs.winehq.org/show_bug.cgi?id=17796
-------------- next part --------------
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index a37606a..1986510 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -1213,13 +1213,17 @@ BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnecti
/* Must be zero */
if(dwReserved)
- return FALSE;
+ return FALSE;
if (lpdwStatus) {
WARN("always returning LAN connection.\n");
*lpdwStatus = INTERNET_CONNECTION_LAN;
}
- return LoadStringW(WININET_hModule, IDS_LANCONNECTION, lpszConnectionName, dwNameLen) > 0;
+
+ if(dwNameLen)
+ LoadStringW(WININET_hModule, IDS_LANCONNECTION, lpszConnectionName, dwNameLen);
+
+ return TRUE;
}
@@ -1235,7 +1239,7 @@ BOOL WINAPI InternetGetConnectedStateExA(LPDWORD lpdwStatus, LPSTR lpszConnectio
TRACE("(%p, %p, %d, 0x%08x)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved);
if (lpszConnectionName && dwNameLen > 0)
- lpwszConnectionName = heap_alloc(dwNameLen * sizeof(WCHAR));
+ lpwszConnectionName = heap_alloc_zero(dwNameLen * sizeof(WCHAR));
rc = InternetGetConnectedStateExW(lpdwStatus,lpwszConnectionName, dwNameLen,
dwReserved);
diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c
index 837e429..ae532a1 100644
--- a/dlls/wininet/tests/internet.c
+++ b/dlls/wininet/tests/internet.c
@@ -1473,19 +1473,16 @@ static void test_InternetGetConnectedStateExA(void)
trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, buffer);
res = pInternetGetConnectedStateExA(NULL, NULL, 0, 0);
-todo_wine
ok(res == TRUE, "Expected TRUE, got %d\n", res);
flags = 0;
res = pInternetGetConnectedStateExA(&flags, NULL, 0, 0);
-todo_wine
ok(res == TRUE, "Expected TRUE, got %d\n", res);
ok(flags, "Expected at least one flag set\n");
buffer[0] = 0;
flags = 0;
res = pInternetGetConnectedStateExA(&flags, buffer, 0, 0);
-todo_wine
ok(res == TRUE, "Expected TRUE, got %d\n", res);
ok(flags, "Expected at least one flag set\n");
ok(!buffer[0], "Buffer must not change, got %02X\n", buffer[0]);
@@ -1515,7 +1512,6 @@ todo_wine
buffer[0] = 0;
flags = 0;
res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
-todo_wine
ok(res == TRUE, "Expected TRUE, got %d\n", res);
ok(flags, "Expected at least one flag set\n");
ok(strlen(buffer) == 0, "Expected 0 bytes, got %u\n", lstrlenA(buffer));
@@ -1540,12 +1536,10 @@ static void test_InternetGetConnectedStateExW(void)
trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, wine_dbgstr_w(buffer));
res = pInternetGetConnectedStateExW(NULL, NULL, 0, 0);
-todo_wine
ok(res == TRUE, "Expected TRUE, got %d\n", res);
flags = 0;
res = pInternetGetConnectedStateExW(&flags, NULL, 0, 0);
-todo_wine
ok(res == TRUE, "Expected TRUE, got %d\n", res);
ok(flags, "Expected at least one flag set\n");
@@ -1554,7 +1548,6 @@ todo_wine
res = pInternetGetConnectedStateExW(&flags, buffer, 0, 0);
ok(res == TRUE, "Expected TRUE, got %d\n", res);
ok(flags, "Expected at least one flag set\n");
-todo_wine
ok(!buffer[0], "Buffer must not change, got %02X\n", buffer[0]);
buffer[0] = 0;
@@ -1582,7 +1575,6 @@ todo_wine
buffer[0] = 0;
flags = 0;
res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
-todo_wine
ok(res == TRUE, "Expected TRUE, got %d\n", res);
ok(flags, "Expected at least one flag set\n");
ok(lstrlenW(buffer) == 0, "Expected 0 bytes, got %u\n", lstrlenW(buffer));
More information about the wine-patches
mailing list