Module: wine Branch: master Commit: 70be64b2ba9704f806ff4b4aab632aea827a2313 URL: http://source.winehq.org/git/wine.git/?a=commit;h=70be64b2ba9704f806ff4b4aab...
Author: Bruno Jesus 00cpxxx@gmail.com Date: Fri Mar 23 00:23:48 2012 -0300
ws2_32: Handle NULL proto in WSAAsyncGetServByName.
---
dlls/ws2_32/async.c | 14 +++++++++++--- dlls/ws2_32/tests/sock.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/dlls/ws2_32/async.c b/dlls/ws2_32/async.c index cc330bb..573349f 100644 --- a/dlls/ws2_32/async.c +++ b/dlls/ws2_32/async.c @@ -384,7 +384,7 @@ HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name, { struct async_query_getservbyname *aq; unsigned int len1 = strlen(name) + 1; - unsigned int len2 = strlen(proto) + 1; + unsigned int len2 = proto ? strlen(proto) + 1 : 0;
TRACE("hwnd %p, msg %04x, name %s, proto %s\n", hWnd, uMsg, debugstr_a(name), debugstr_a(proto));
@@ -393,10 +393,18 @@ HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name, SetLastError( WSAEWOULDBLOCK ); return 0; } + aq->serv_name = (char *)(aq + 1); - aq->serv_proto = aq->serv_name + len1; strcpy( aq->serv_name, name ); - strcpy( aq->serv_proto, proto ); + + if (proto) + { + aq->serv_proto = aq->serv_name + len1; + strcpy( aq->serv_proto, proto ); + } + else + aq->serv_proto = NULL; + return run_query( hWnd, uMsg, async_getservbyname, &aq->query, sbuf, buflen ); }
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 2de23c9..f4cc909 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -5203,6 +5203,33 @@ static void test_WSAAsyncGetServByPort(void) DestroyWindow(hwnd); }
+static void test_WSAAsyncGetServByName(void) +{ + HWND hwnd = create_async_message_window(); + HANDLE ret; + char buffer[MAXGETHOSTSTRUCT]; + + if (!hwnd) + return; + + /* FIXME: The asynchronous window messages should be tested. */ + + /* Parameters are not checked when initiating the asynchronous operation. */ + ret = WSAAsyncGetServByName(hwnd, WM_ASYNCCOMPLETE, "", NULL, NULL, 0); + ok(ret != NULL, "WSAAsyncGetServByName returned NULL\n"); + + ret = WSAAsyncGetServByName(hwnd, WM_ASYNCCOMPLETE, "", "", buffer, MAXGETHOSTSTRUCT); + ok(ret != NULL, "WSAAsyncGetServByName returned NULL\n"); + + ret = WSAAsyncGetServByName(hwnd, WM_ASYNCCOMPLETE, "http", NULL, NULL, 0); + ok(ret != NULL, "WSAAsyncGetServByName returned NULL\n"); + + ret = WSAAsyncGetServByName(hwnd, WM_ASYNCCOMPLETE, "http", "tcp", buffer, MAXGETHOSTSTRUCT); + ok(ret != NULL, "WSAAsyncGetServByName returned NULL\n"); + + DestroyWindow(hwnd); +} + static void test_completion_port(void) { HANDLE previous_port, io_port; @@ -5770,6 +5797,7 @@ START_TEST( sock ) test_sioRoutingInterfaceQuery();
test_WSAAsyncGetServByPort(); + test_WSAAsyncGetServByName();
test_completion_port();