iphlpapi: Improve parameter checking for IcmpSendEcho().

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2018-08-05 11:05:16 +08:00 committed by Alexandre Julliard
parent 3825be96f3
commit 6ec5b57a1f
2 changed files with 7 additions and 10 deletions

View File

@ -288,11 +288,16 @@ DWORD WINAPI IcmpSendEcho(
if (IcmpHandle==INVALID_HANDLE_VALUE) {
/* FIXME: in fact win98 seems to ignore the handle value !!! */
SetLastError(ERROR_INVALID_HANDLE);
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
if (ReplySize<sizeof(ICMP_ECHO_REPLY)+ICMP_MINLEN) {
if (!ReplyBuffer||!ReplySize) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
if (ReplySize<sizeof(ICMP_ECHO_REPLY)) {
SetLastError(IP_BUF_TOO_SMALL);
return 0;
}

View File

@ -966,7 +966,6 @@ static void testIcmpSendEcho(void)
ret = pIcmpSendEcho(INVALID_HANDLE_VALUE, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000);
error = GetLastError();
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
todo_wine
ok (error == ERROR_INVALID_PARAMETER
|| broken(error == ERROR_INVALID_HANDLE) /* <= 2003 */,
"expected 87, got %d\n", error);
@ -1009,20 +1008,16 @@ todo_wine
error = GetLastError();
ok (ret, "IcmpSendEcho failed unexpectedly with error %d\n", error);
if (0) /* crashes in wine, remove IF when fixed */
{
SetLastError(0xdeadbeef);
ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, NULL, replysz, 1000);
error = GetLastError();
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
ok (error == ERROR_INVALID_PARAMETER, "expected 87, got %d\n", error);
}
SetLastError(0xdeadbeef);
ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, 0, 1000);
error = GetLastError();
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
todo_wine
ok (error == ERROR_INVALID_PARAMETER
|| broken(error == ERROR_INSUFFICIENT_BUFFER) /* <= 2003 */,
"expected 87, got %d\n", error);
@ -1031,7 +1026,6 @@ todo_wine
ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, NULL, 0, 1000);
error = GetLastError();
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
todo_wine
ok (error == ERROR_INVALID_PARAMETER
|| broken(error == ERROR_INSUFFICIENT_BUFFER) /* <= 2003 */,
"expected 87, got %d\n", error);
@ -1049,7 +1043,6 @@ todo_wine
replysz = sizeof(ICMP_ECHO_REPLY);
ret = pIcmpSendEcho(icmp, address, senddata, 0, NULL, replydata, replysz, 1000);
error = GetLastError();
todo_wine
ok (ret, "IcmpSendEcho failed unexpectedly with error %d\n", error);
SetLastError(0xdeadbeef);
@ -1071,7 +1064,6 @@ todo_wine
ret = pIcmpSendEcho(icmp, address, senddata, ICMP_MINLEN, NULL, replydata, replysz - 1, 1000);
error = GetLastError();
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
todo_wine
ok (error == IP_GENERAL_FAILURE
|| broken(error == IP_BUF_TOO_SMALL) /* <= 2003 */,
"expected 11050, got %d\n", error);