As shown by the testbot, doubling is not always sufficient.
From: Hans Leidekker hans@codeweavers.com
As shown by the testbot, doubling is not always sufficient. --- dlls/iphlpapi/tests/iphlpapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index 090cd2c9ff9..9ba6709e26a 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -1765,7 +1765,7 @@ static void test_GetAdaptersAddresses(void) free(ptr);
/* higher size must not be changed to lower size */ - size *= 2; + size *= 4; osize = size; ptr = malloc(osize); ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_SKIP_FRIENDLY_NAME, NULL, ptr, &osize);
From: Hans Leidekker hans@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54588 --- dlls/iphlpapi/tests/iphlpapi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index 9ba6709e26a..f05b2b5e8f1 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -1878,6 +1878,7 @@ static void test_GetExtendedTcpTable(void) ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_BASIC_ALL, 0 ); ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", ret );
+ size *= 4; table = malloc( size ); ret = pGetExtendedTcpTable( table, &size, TRUE, AF_INET, TCP_TABLE_BASIC_ALL, 0 ); ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); @@ -1887,6 +1888,7 @@ static void test_GetExtendedTcpTable(void) ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_BASIC_LISTENER, 0 ); ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", ret );
+ size *= 4; table = malloc( size ); ret = pGetExtendedTcpTable( table, &size, TRUE, AF_INET, TCP_TABLE_BASIC_LISTENER, 0 ); ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); @@ -1896,6 +1898,7 @@ static void test_GetExtendedTcpTable(void) ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0 ); ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", ret );
+ size *= 4; table_pid = malloc( size ); ret = pGetExtendedTcpTable( table_pid, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0 ); ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); @@ -1905,6 +1908,7 @@ static void test_GetExtendedTcpTable(void) ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_LISTENER, 0 ); ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", ret );
+ size *= 4; table_pid = malloc( size ); ret = pGetExtendedTcpTable( table_pid, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_LISTENER, 0 ); ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); @@ -1914,6 +1918,7 @@ static void test_GetExtendedTcpTable(void) ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0 ); ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", ret );
+ size *= 4; table_module = malloc( size ); ret = pGetExtendedTcpTable( table_module, &size, TRUE, AF_INET, TCP_TABLE_OWNER_MODULE_ALL, 0 ); ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); @@ -1923,6 +1928,7 @@ static void test_GetExtendedTcpTable(void) ret = pGetExtendedTcpTable( NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_MODULE_LISTENER, 0 ); ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", ret );
+ size *= 4; table_module = malloc( size ); ret = pGetExtendedTcpTable( table_module, &size, TRUE, AF_INET, TCP_TABLE_OWNER_MODULE_LISTENER, 0 ); ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); @@ -1997,6 +2003,7 @@ static void test_GetExtendedUdpTable(void) ret = pGetExtendedUdpTable( NULL, &size, TRUE, AF_INET, UDP_TABLE_BASIC, 0 ); ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", ret );
+ size *= 4; table = malloc( size ); ret = pGetExtendedUdpTable( table, &size, TRUE, AF_INET, UDP_TABLE_BASIC, 0 ); ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); @@ -2006,6 +2013,7 @@ static void test_GetExtendedUdpTable(void) ret = pGetExtendedUdpTable( NULL, &size, TRUE, AF_INET, UDP_TABLE_OWNER_PID, 0 ); ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", ret );
+ size *= 4; table_pid = malloc( size ); ret = pGetExtendedUdpTable( table_pid, &size, TRUE, AF_INET, UDP_TABLE_OWNER_PID, 0 ); ok( ret == ERROR_SUCCESS, "got %lu\n", ret ); @@ -2015,6 +2023,7 @@ static void test_GetExtendedUdpTable(void) ret = pGetExtendedUdpTable( NULL, &size, TRUE, AF_INET, UDP_TABLE_OWNER_MODULE, 0 ); ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", ret );
+ size *= 4; table_module = malloc( size ); ret = pGetExtendedUdpTable( table_module, &size, TRUE, AF_INET, UDP_TABLE_OWNER_MODULE, 0 ); ok( ret == ERROR_SUCCESS, "got %lu\n", ret );
Is there a reason not to use a loop here? That would be more reliable.
This test is supposed to show that the size parameter is not updated on success. The only way to do that is to pass a too large size, which of course we can't be certain about.
Right, but we could still loop on `ERROR_BUFFER_OVERFLOW`.