Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
dc02bbee
Commit
dc02bbee
authored
Jan 20, 2021
by
Hans Leidekker
Committed by
Alexandre Julliard
Jan 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Fix buffer size query in WSAAddressToStringW.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e7dc8237
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
20 deletions
+23
-20
socket.c
dlls/ws2_32/socket.c
+5
-20
sock.c
dlls/ws2_32/tests/sock.c
+18
-0
No files found.
dlls/ws2_32/socket.c
View file @
dc02bbee
...
...
@@ -8518,30 +8518,15 @@ INT WINAPI WSAAddressToStringW( LPSOCKADDR sockaddr, DWORD len,
LPWSAPROTOCOL_INFOW
info
,
LPWSTR
string
,
LPDWORD
lenstr
)
{
INT
ret
;
DWORD
size
;
WCHAR
buffer
[
54
];
/* 32 digits + 7':' + '[' + '%" + 5 digits + ']:' + 5 digits + '\0' */
CHAR
bufAddr
[
54
];
INT
ret
;
char
buf
[
54
];
/* 32 digits + 7':' + '[' + '%" + 5 digits + ']:' + 5 digits + '\0' */
TRACE
(
"(%p, %d, %p, %p, %p)
\n
"
,
sockaddr
,
len
,
info
,
string
,
lenstr
);
size
=
*
lenstr
;
ret
=
WSAAddressToStringA
(
sockaddr
,
len
,
NULL
,
bufAddr
,
&
size
);
if
(
ret
)
return
ret
;
if
((
ret
=
WSAAddressToStringA
(
sockaddr
,
len
,
NULL
,
buf
,
lenstr
)))
return
ret
;
MultiByteToWideChar
(
CP_ACP
,
0
,
bufAddr
,
size
,
buffer
,
ARRAY_SIZE
(
buffer
));
if
(
*
lenstr
<
size
)
{
*
lenstr
=
size
;
SetLastError
(
WSAEFAULT
);
return
SOCKET_ERROR
;
}
TRACE
(
"=> %s,%u bytes
\n
"
,
debugstr_w
(
buffer
),
size
);
*
lenstr
=
size
;
lstrcpyW
(
string
,
buffer
);
MultiByteToWideChar
(
CP_ACP
,
0
,
buf
,
*
lenstr
,
string
,
*
lenstr
);
TRACE
(
"=> %s,%u chars
\n
"
,
debugstr_w
(
string
),
*
lenstr
);
return
0
;
}
...
...
dlls/ws2_32/tests/sock.c
View file @
dc02bbee
...
...
@@ -2923,11 +2923,29 @@ static void test_WSAAddressToString(void)
sockaddr
.
sin_family
=
AF_INET
;
sockaddr
.
sin_addr
.
s_addr
=
0
;
sockaddr
.
sin_port
=
0
;
WSASetLastError
(
0xdeadbeef
);
ret
=
WSAAddressToStringA
(
(
SOCKADDR
*
)
&
sockaddr
,
sizeof
(
sockaddr
),
NULL
,
output
,
&
len
);
ok
(
ret
==
SOCKET_ERROR
,
"WSAAddressToStringA() returned %d, expected SOCKET_ERROR
\n
"
,
ret
);
ok
(
WSAGetLastError
()
==
WSAEFAULT
,
"WSAAddressToStringA() gave error %d, expected WSAEFAULT
\n
"
,
WSAGetLastError
()
);
ok
(
len
==
8
,
"WSAAddressToStringA() gave length %d, expected 8
\n
"
,
len
);
len
=
0
;
sockaddr
.
sin_family
=
AF_INET
;
sockaddr
.
sin_addr
.
s_addr
=
0
;
sockaddr
.
sin_port
=
0
;
WSASetLastError
(
0xdeadbeef
);
ret
=
WSAAddressToStringW
(
(
SOCKADDR
*
)
&
sockaddr
,
sizeof
(
sockaddr
),
NULL
,
NULL
,
&
len
);
ok
(
ret
==
SOCKET_ERROR
,
"got %d
\n
"
,
ret
);
ok
(
WSAGetLastError
()
==
WSAEFAULT
,
"got %08x
\n
"
,
WSAGetLastError
()
);
ok
(
len
==
8
,
"got %u
\n
"
,
len
);
len
=
ARRAY_SIZE
(
outputW
);
memset
(
outputW
,
0
,
sizeof
(
outputW
)
);
ret
=
WSAAddressToStringW
(
(
SOCKADDR
*
)
&
sockaddr
,
sizeof
(
sockaddr
),
NULL
,
outputW
,
&
len
);
ok
(
!
ret
,
"WSAAddressToStringW() returned %d
\n
"
,
ret
);
ok
(
len
==
8
,
"got %u
\n
"
,
len
);
ok
(
!
wcscmp
(
outputW
,
L"0.0.0.0"
),
"got %s
\n
"
,
wine_dbgstr_w
(
outputW
)
);
for
(
i
=
0
;
i
<
2
;
i
++
)
{
for
(
j
=
0
;
j
<
ARRAY_SIZE
(
ipv4_tests
);
j
++
)
...
...
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