Zhiyi Zhang : iphlpapi: Improve parameter checking for IcmpSendEcho().
Module: wine Branch: master Commit: 6ec5b57a1fc8302a2f44c15541fc9499c21cf193 URL: https://source.winehq.org/git/wine.git/?a=commit;h=6ec5b57a1fc8302a2f44c1554... Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Sun Aug 5 11:05:16 2018 +0800 iphlpapi: Improve parameter checking for IcmpSendEcho(). Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- 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 496ad2a..0dc2f12 100644 --- a/dlls/iphlpapi/icmp.c +++ b/dlls/iphlpapi/icmp.c @@ -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 (!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 609abb3..0d35c26 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);
participants (1)
-
Alexandre Julliard