Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/iphlpapi/icmp.c | 9 +++++++-- dlls/iphlpapi/tests/iphlpapi.c | 8 -------- 2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/dlls/iphlpapi/icmp.c b/dlls/iphlpapi/icmp.c index 159b7bef18..3e53bfd409 100644 --- a/dlls/iphlpapi/icmp.c +++ b/dlls/iphlpapi/icmp.c @@ -290,11 +290,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 (!ReplyBuffer||!ReplySize) { + SetLastError(ERROR_INVALID_PARAMETER); return 0; }
- if (ReplySize<sizeof(ICMP_ECHO_REPLY)+ICMP_MINLEN) { + if (ReplySize<sizeof(ICMP_ECHO_REPLY)) { SetLastError(IP_BUF_TOO_SMALL); return 0; } diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index f964878d68..ff381c5e29 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -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);