Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
9edafeb7
Commit
9edafeb7
authored
Jun 01, 2011
by
Andrew Nguyen
Committed by
Alexandre Julliard
Jun 01, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Avoid a crash with an optional pointer in WSAAsyncGetServByPort.
parent
2c747964
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
4 deletions
+75
-4
async.c
dlls/ws2_32/async.c
+12
-4
sock.c
dlls/ws2_32/tests/sock.c
+63
-0
No files found.
dlls/ws2_32/async.c
View file @
9edafeb7
...
...
@@ -407,7 +407,7 @@ HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
LPCSTR
proto
,
LPSTR
sbuf
,
INT
buflen
)
{
struct
async_query_getservbyport
*
aq
;
unsigned
int
len
=
strlen
(
proto
)
+
1
;
unsigned
int
len
=
proto
?
strlen
(
proto
)
+
1
:
0
;
TRACE
(
"hwnd %p, msg %04x, port %i, proto %s
\n
"
,
hWnd
,
uMsg
,
port
,
debugstr_a
(
proto
));
...
...
@@ -416,9 +416,17 @@ HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
SetLastError
(
WSAEWOULDBLOCK
);
return
0
;
}
aq
->
serv_proto
=
(
char
*
)(
aq
+
1
);
aq
->
serv_port
=
port
;
strcpy
(
aq
->
serv_proto
,
proto
);
if
(
proto
)
{
aq
->
serv_proto
=
(
char
*
)(
aq
+
1
);
strcpy
(
aq
->
serv_proto
,
proto
);
}
else
aq
->
serv_proto
=
NULL
;
aq
->
serv_port
=
port
;
return
run_query
(
hWnd
,
uMsg
,
async_getservbyport
,
&
aq
->
query
,
sbuf
,
buflen
);
}
...
...
dlls/ws2_32/tests/sock.c
View file @
9edafeb7
...
...
@@ -4810,6 +4810,67 @@ static void test_synchronous_WSAIoctl(void)
CloseHandle
(
previous_port
);
}
#define WM_ASYNCCOMPLETE (WM_USER + 100)
static
HWND
create_async_message_window
(
void
)
{
static
const
char
class_name
[]
=
"ws2_32 async message window class"
;
WNDCLASSEXA
wndclass
;
HWND
hWnd
;
wndclass
.
cbSize
=
sizeof
(
wndclass
);
wndclass
.
style
=
CS_HREDRAW
|
CS_VREDRAW
;
wndclass
.
lpfnWndProc
=
DefWindowProcA
;
wndclass
.
cbClsExtra
=
0
;
wndclass
.
cbWndExtra
=
0
;
wndclass
.
hInstance
=
GetModuleHandleA
(
NULL
);
wndclass
.
hIcon
=
LoadIconA
(
NULL
,
IDI_APPLICATION
);
wndclass
.
hIconSm
=
LoadIconA
(
NULL
,
IDI_APPLICATION
);
wndclass
.
hCursor
=
LoadCursorA
(
NULL
,
IDC_ARROW
);
wndclass
.
hbrBackground
=
(
HBRUSH
)(
COLOR_WINDOW
+
1
);
wndclass
.
lpszClassName
=
class_name
;
wndclass
.
lpszMenuName
=
NULL
;
RegisterClassExA
(
&
wndclass
);
hWnd
=
CreateWindow
(
class_name
,
"ws2_32 async message window"
,
WS_OVERLAPPEDWINDOW
,
0
,
0
,
500
,
500
,
NULL
,
NULL
,
GetModuleHandleA
(
NULL
),
NULL
);
if
(
!
hWnd
)
{
ok
(
0
,
"failed to create window: %u
\n
"
,
GetLastError
());
return
NULL
;
}
return
hWnd
;
}
static
void
test_WSAAsyncGetServByPort
(
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
=
WSAAsyncGetServByPort
(
NULL
,
0
,
0
,
NULL
,
NULL
,
0
);
ok
(
ret
!=
NULL
,
"WSAAsyncGetServByPort returned NULL
\n
"
);
ret
=
WSAAsyncGetServByPort
(
hwnd
,
WM_ASYNCCOMPLETE
,
0
,
NULL
,
NULL
,
0
);
ok
(
ret
!=
NULL
,
"WSAAsyncGetServByPort returned NULL
\n
"
);
ret
=
WSAAsyncGetServByPort
(
hwnd
,
WM_ASYNCCOMPLETE
,
htons
(
80
),
NULL
,
NULL
,
0
);
ok
(
ret
!=
NULL
,
"WSAAsyncGetServByPort returned NULL
\n
"
);
ret
=
WSAAsyncGetServByPort
(
hwnd
,
WM_ASYNCCOMPLETE
,
htons
(
80
),
NULL
,
buffer
,
MAXGETHOSTSTRUCT
);
ok
(
ret
!=
NULL
,
"WSAAsyncGetServByPort returned NULL
\n
"
);
DestroyWindow
(
hwnd
);
}
/**************** Main program ***************/
START_TEST
(
sock
)
...
...
@@ -4870,6 +4931,8 @@ START_TEST( sock )
test_sioRoutingInterfaceQuery
();
test_WSAAsyncGetServByPort
();
/* this is a io heavy test, do it at the end so the kernel doesn't start dropping packets */
test_send
();
test_synchronous_WSAIoctl
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment