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
0298165b
Commit
0298165b
authored
Sep 17, 2013
by
Bruno Jesus
Committed by
Alexandre Julliard
Sep 17, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Filter invalid socket parameters and return the appropriate error.
parent
35e54fa5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
13 deletions
+55
-13
socket.c
dlls/ws2_32/socket.c
+43
-5
sock.c
dlls/ws2_32/tests/sock.c
+12
-8
No files found.
dlls/ws2_32/socket.c
View file @
0298165b
...
...
@@ -5868,6 +5868,7 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol,
{
SOCKET
ret
;
DWORD
err
;
int
unixaf
,
unixtype
;
/*
FIXME: The "advanced" parameters of WSASocketW (lpProtocolInfo,
...
...
@@ -5913,14 +5914,50 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol,
}
}
/* convert the socket family and type */
af
=
convert_af_w2u
(
af
);
type
=
convert_socktype_w2u
(
type
);
/* convert the socket family, type and protocol */
unixaf
=
convert_af_w2u
(
af
);
unixtype
=
convert_socktype_w2u
(
type
);
protocol
=
convert_proto_w2u
(
protocol
);
if
(
unixaf
==
AF_UNSPEC
)
unixaf
=
-
1
;
/* filter invalid parameters */
if
(
protocol
<
0
)
{
/* the type could not be converted */
if
(
type
&&
unixtype
<
0
)
{
err
=
WSAESOCKTNOSUPPORT
;
goto
done
;
}
err
=
WSAEPROTONOSUPPORT
;
goto
done
;
}
if
(
unixaf
<
0
)
{
/* both family and protocol can't be invalid */
if
(
protocol
<=
0
)
{
err
=
WSAEINVAL
;
goto
done
;
}
/* family could not be converted and neither socket type */
if
(
unixtype
<
0
&&
af
>=
0
)
{
err
=
WSAESOCKTNOSUPPORT
;
goto
done
;
}
err
=
WSAEAFNOSUPPORT
;
goto
done
;
}
SERVER_START_REQ
(
create_socket
)
{
req
->
family
=
af
;
req
->
type
=
type
;
req
->
family
=
unix
af
;
req
->
type
=
unix
type
;
req
->
protocol
=
protocol
;
req
->
access
=
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
;
req
->
attributes
=
OBJ_INHERIT
;
...
...
@@ -5952,6 +5989,7 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol,
err
=
WSAEPROTONOSUPPORT
;
}
done:
WARN
(
"
\t\t
failed, error %d!
\n
"
,
err
);
SetLastError
(
err
);
return
INVALID_SOCKET
;
...
...
dlls/ws2_32/tests/sock.c
View file @
0298165b
...
...
@@ -1784,7 +1784,6 @@ static void test_WSASocket(void)
ok
(
WSASocketA
(
0
,
0
,
0
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
todo_wine
ok
(
err
==
WSAEINVAL
,
"Expected 10022, received %d
\n
"
,
err
);
sock
=
WSASocketA
(
AF_INET
,
0
,
0
,
NULL
,
0
,
0
);
...
...
@@ -1811,10 +1810,21 @@ todo_wine
ok
(
WSASocketA
(
0
,
-
1
,
0
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
todo_wine
ok
(
err
==
WSAEINVAL
,
"Expected 10022, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
ok
(
WSASocketA
(
AF_INET
,
-
1
,
0
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
ok
(
err
==
WSAESOCKTNOSUPPORT
,
"Expected 10044, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
ok
(
WSASocketA
(
AF_INET
,
0
,
-
1
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
ok
(
err
==
WSAEPROTONOSUPPORT
,
"Expected 10043, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
ok
(
WSASocketA
(
0
,
-
1
,
-
1
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
...
...
@@ -1824,7 +1834,6 @@ todo_wine
ok
(
WSASocketA
(
-
1
,
SOCK_STREAM
,
IPPROTO_UDP
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
todo_wine
ok
(
err
==
WSAEAFNOSUPPORT
,
"Expected 10047, received %d
\n
"
,
err
);
sock
=
WSASocketA
(
AF_INET
,
0
,
IPPROTO_TCP
,
NULL
,
0
,
0
);
...
...
@@ -1835,14 +1844,12 @@ todo_wine
ok
(
WSASocketA
(
0
,
SOCK_STREAM
,
0
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
todo_wine
ok
(
err
==
WSAEINVAL
,
"Expected 10022, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
ok
(
WSASocketA
(
0
,
0
,
0xdead
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
todo_wine
ok
(
err
==
WSAEPROTONOSUPPORT
,
"Expected 10043, received %d
\n
"
,
err
);
SetLastError
(
0xdeadbeef
);
...
...
@@ -1855,7 +1862,6 @@ todo_wine
ok
(
WSASocketA
(
0
,
0xdead
,
0
,
NULL
,
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
todo_wine
ok
(
err
==
WSAEINVAL
,
"Expected 10022, received %d
\n
"
,
err
);
sock
=
WSASocketA
(
0
,
0
,
IPPROTO_TCP
,
NULL
,
0
,
0
);
...
...
@@ -1917,7 +1923,6 @@ todo_wine
ok
(
WSASocketA
(
0
,
0
,
IPPROTO_UDP
,
&
pi
[
0
],
0
,
0
)
==
INVALID_SOCKET
,
"WSASocketA should have failed
\n
"
);
err
=
WSAGetLastError
();
todo_wine
ok
(
err
==
WSAEAFNOSUPPORT
,
"Expected 10047, received %d
\n
"
,
err
);
pi
[
0
].
iProtocol
=
0
;
...
...
@@ -1932,7 +1937,6 @@ todo_wine
else
{
err
=
WSAGetLastError
();
todo_wine
ok
(
err
==
WSAEAFNOSUPPORT
,
"Expected 10047, received %d
\n
"
,
err
);
}
...
...
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