Bruno Jesus : ws2_32: Avoid an unhandled exception in WSAIoctl.
Alexandre Julliard
julliard at winehq.org
Tue Sep 6 11:35:51 CDT 2011
Module: wine
Branch: master
Commit: 312f50a26f1c027488d188801f2574eb559d6521
URL: http://source.winehq.org/git/wine.git/?a=commit;h=312f50a26f1c027488d188801f2574eb559d6521
Author: Bruno Jesus <00cpxxx at gmail.com>
Date: Mon Sep 5 23:04:23 2011 -0300
ws2_32: Avoid an unhandled exception in WSAIoctl.
---
dlls/ws2_32/socket.c | 15 +++++++++------
dlls/ws2_32/tests/sock.c | 13 +++++++++++++
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 64abd93..ff3c282 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -3365,17 +3365,20 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
}
case WS_SIO_KEEPALIVE_VALS:
{
- struct tcp_keepalive *k = in_buff;
- int keepalive = k->onoff ? 1 : 0;
- int keepidle = k->keepalivetime / 1000;
- int keepintvl = k->keepaliveinterval / 1000;
+ struct tcp_keepalive *k;
+ int keepalive, keepidle, keepintvl;
- if (!in_buff)
+ if (!in_buff || in_size < sizeof(struct tcp_keepalive))
{
- WSASetLastError(WSAEINVAL);
+ WSASetLastError(WSAEFAULT);
return SOCKET_ERROR;
}
+ k = in_buff;
+ keepalive = k->onoff ? 1 : 0;
+ keepidle = k->keepalivetime / 1000;
+ keepintvl = k->keepaliveinterval / 1000;
+
TRACE("onoff: %d, keepalivetime: %d, keepaliveinterval: %d\n", keepalive, keepidle, keepintvl);
fd = get_sock_fd(s, 0, NULL);
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 9e6912c..fd6b8c2 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -26,6 +26,7 @@
#include <windows.h>
#include <ws2tcpip.h>
#include <mswsock.h>
+#include <mstcpip.h>
#include <stdio.h>
#include "wine/test.h"
@@ -2960,6 +2961,18 @@ static void test_ioctlsocket(void)
ret = ioctlsocket(sock, SIOCATMARK, &arg);
if(ret != SOCKET_ERROR)
todo_wine ok(arg, "expected a non-zero value\n");
+
+ ret = WSAIoctl(sock, SIO_KEEPALIVE_VALS, &arg, 0, NULL, 0, &arg, NULL, NULL);
+ ok(ret == SOCKET_ERROR, "WSAIoctl succeeded unexpectedly\n");
+ ret = WSAGetLastError();
+ ok(ret == WSAEFAULT || broken(ret == WSAEINVAL), "expected WSAEFAULT, got %d instead\n", ret);
+
+ ret = WSAIoctl(sock, SIO_KEEPALIVE_VALS, NULL, sizeof(struct tcp_keepalive), NULL, 0, &arg, NULL, NULL);
+ ok(ret == SOCKET_ERROR, "WSAIoctl succeeded unexpectedly\n");
+ ret = WSAGetLastError();
+ ok(ret == WSAEFAULT || broken(ret == WSAEINVAL), "expected WSAEFAULT, got %d instead\n", ret);
+
+ closesocket(sock);
}
static int drain_pause=0;
More information about the wine-cvs
mailing list