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
1cf9436e
Commit
1cf9436e
authored
Jun 14, 2007
by
Damjan Jovanovic
Committed by
Alexandre Julliard
Jun 15, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: getsockname should fail on unbound socket.
parent
3c3a879a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
socket.c
dlls/ws2_32/socket.c
+33
-0
sock.c
dlls/ws2_32/tests/sock.c
+10
-0
No files found.
dlls/ws2_32/socket.c
View file @
1cf9436e
...
...
@@ -927,6 +927,35 @@ static unsigned int ws_sockaddr_ws2u(const struct WS_sockaddr* wsaddr, int wsadd
return
uaddrlen
;
}
static
BOOL
is_sockaddr_bound
(
const
struct
sockaddr
*
uaddr
,
int
uaddrlen
)
{
switch
(
uaddr
->
sa_family
)
{
#ifdef HAVE_IPX
case
AF_IPX
:
FIXME
(
"don't know how to tell if IPX socket is bound, assuming it is!
\n
"
);
return
TRUE
;
#endif
case
AF_INET6
:
{
static
const
struct
sockaddr_in6
emptyAddr
;
const
struct
sockaddr_in6
*
in6
=
(
const
struct
sockaddr_in6
*
)
uaddr
;
return
in6
->
sin6_port
||
memcmp
(
&
in6
->
sin6_addr
,
&
emptyAddr
.
sin6_addr
,
sizeof
(
struct
in6_addr
));
}
case
AF_INET
:
{
static
const
struct
sockaddr_in
emptyAddr
;
const
struct
sockaddr_in
*
in
=
(
const
struct
sockaddr_in
*
)
uaddr
;
return
in
->
sin_port
||
memcmp
(
&
in
->
sin_addr
,
&
emptyAddr
.
sin_addr
,
sizeof
(
struct
in_addr
));
}
case
AF_UNSPEC
:
return
FALSE
;
default:
FIXME
(
"unknown address family %d
\n
"
,
uaddr
->
sa_family
);
return
TRUE
;
}
}
/* Returns 0 if successful, -1 if the buffer is too small */
static
int
ws_sockaddr_u2ws
(
const
struct
sockaddr
*
uaddr
,
struct
WS_sockaddr
*
wsaddr
,
int
*
wsaddrlen
)
{
...
...
@@ -1590,6 +1619,10 @@ int WINAPI WS_getsockname(SOCKET s, struct WS_sockaddr *name, int *namelen)
{
SetLastError
(
wsaErrno
());
}
else
if
(
!
is_sockaddr_bound
(
&
uaddr
.
addr
,
uaddrlen
))
{
SetLastError
(
WSAEINVAL
);
}
else
if
(
ws_sockaddr_u2ws
(
&
uaddr
.
addr
,
name
,
namelen
)
!=
0
)
{
/* The buffer was too small */
...
...
dlls/ws2_32/tests/sock.c
View file @
1cf9436e
...
...
@@ -1644,6 +1644,16 @@ static void test_getsockname(void)
return
;
}
memcpy
(
&
sa_get
,
&
sa_set
,
sizeof
(
sa_set
));
if
(
getsockname
(
sock
,
(
struct
sockaddr
*
)
&
sa_get
,
&
sa_get_len
)
==
0
)
ok
(
0
,
"getsockname on unbound socket should fail
\n
"
);
else
{
ok
(
WSAGetLastError
()
==
WSAEINVAL
,
"getsockname on unbound socket "
"failed with %d, expected %d
\n
"
,
WSAGetLastError
(),
WSAEINVAL
);
ok
(
memcmp
(
&
sa_get
,
&
sa_set
,
sizeof
(
sa_get
))
==
0
,
"failed getsockname modified sockaddr when it shouldn't
\n
"
);
}
if
(
bind
(
sock
,
(
struct
sockaddr
*
)
&
sa_set
,
sa_set_len
)
<
0
){
trace
(
"Failed to bind socket: %d
\n
"
,
WSAGetLastError
());
closesocket
(
sock
);
...
...
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