mirror of
https://github.com/reactos/reactos.git
synced 2025-06-30 21:01:21 +00:00
[IPHLPAPI_APITEST] Avoid crash on ROS and failure on Windows. CORE-14411
- Make the reply buffer for IcmpSendEcho large enough to hold the reply, even when testing a smaller size. This avoids a buffer overflow with ROS's broken implementation. - Avoid unnecessary initialization. - Fix IcmpSendEcho return value check to succeed on Win2003. - Don't free a string literal in the GetInterfaceName test.
This commit is contained in:
parent
34b0f3e4f8
commit
93edd2a185
2 changed files with 6 additions and 7 deletions
|
@ -361,7 +361,6 @@ test_GetInterfaceName(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiReturn = RtlGUIDFromString(&GuidString, &AdapterGUID);
|
ApiReturn = RtlGUIDFromString(&GuidString, &AdapterGUID);
|
||||||
RtlFreeUnicodeString(&GuidString);
|
|
||||||
if (ApiReturn != 0)
|
if (ApiReturn != 0)
|
||||||
{
|
{
|
||||||
skip("RtlGUIDFromString failed. Can't proceed\n");
|
skip("RtlGUIDFromString failed. Can't proceed\n");
|
||||||
|
|
|
@ -90,7 +90,7 @@ test_IcmpSendEcho(void)
|
||||||
unsigned long ipaddr = INADDR_NONE;
|
unsigned long ipaddr = INADDR_NONE;
|
||||||
DWORD bRet = 0, error = 0;
|
DWORD bRet = 0, error = 0;
|
||||||
char SendData[32] = "Data Buffer";
|
char SendData[32] = "Data Buffer";
|
||||||
PVOID ReplyBuffer = NULL;
|
PVOID ReplyBuffer;
|
||||||
DWORD ReplySize = 0;
|
DWORD ReplySize = 0;
|
||||||
|
|
||||||
SetLastError(0xDEADBEEF);
|
SetLastError(0xDEADBEEF);
|
||||||
|
@ -102,27 +102,27 @@ test_IcmpSendEcho(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
ipaddr = 0x08080808; // 8.8.8.8
|
ipaddr = 0x08080808; // 8.8.8.8
|
||||||
|
ReplyBuffer = malloc(sizeof(ICMP_ECHO_REPLY) + sizeof(SendData));
|
||||||
|
|
||||||
ReplySize = sizeof(ICMP_ECHO_REPLY);
|
ReplySize = sizeof(ICMP_ECHO_REPLY);
|
||||||
ReplyBuffer = malloc(ReplySize);
|
|
||||||
SetLastError(0xDEADBEEF);
|
SetLastError(0xDEADBEEF);
|
||||||
bRet = IcmpSendEcho(hIcmp, ipaddr, SendData, sizeof(SendData),
|
bRet = IcmpSendEcho(hIcmp, ipaddr, SendData, sizeof(SendData),
|
||||||
NULL, ReplyBuffer, ReplySize, 5000);
|
NULL, ReplyBuffer, ReplySize, 5000);
|
||||||
|
|
||||||
ok(!bRet, "IcmpSendEcho succeeded unexpectedly\n");
|
ok(!bRet, "IcmpSendEcho succeeded unexpectedly\n");
|
||||||
error = GetLastError();
|
error = GetLastError();
|
||||||
ok(error == IP_GENERAL_FAILURE, "IcmpSendEcho returned unexpected error: %lu\n", error);
|
ok(error == IP_BUF_TOO_SMALL /* Win2003 */ ||
|
||||||
free(ReplyBuffer);
|
error == IP_GENERAL_FAILURE /* Win10 */,
|
||||||
|
"IcmpSendEcho returned unexpected error: %lu\n", error);
|
||||||
|
|
||||||
ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData);
|
ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData);
|
||||||
ReplyBuffer = malloc(ReplySize);
|
|
||||||
SetLastError(0xDEADBEEF);
|
SetLastError(0xDEADBEEF);
|
||||||
bRet = IcmpSendEcho(hIcmp, ipaddr, SendData, sizeof(SendData),
|
bRet = IcmpSendEcho(hIcmp, ipaddr, SendData, sizeof(SendData),
|
||||||
NULL, ReplyBuffer, ReplySize, 5000);
|
NULL, ReplyBuffer, ReplySize, 5000);
|
||||||
|
|
||||||
ok(bRet, "IcmpSendEcho failed unexpectedly: %lu\n", GetLastError());
|
ok(bRet, "IcmpSendEcho failed unexpectedly: %lu\n", GetLastError());
|
||||||
free(ReplyBuffer);
|
|
||||||
|
|
||||||
|
free(ReplyBuffer);
|
||||||
IcmpCloseHandle(hIcmp);
|
IcmpCloseHandle(hIcmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue