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
1d1faa02
Commit
1d1faa02
authored
Sep 05, 2013
by
Bruno Jesus
Committed by
Alexandre Julliard
Sep 05, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Cope with invalid protocols in WSAEnumProtocols.
parent
533730de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
18 deletions
+91
-18
socket.c
dlls/ws2_32/socket.c
+33
-12
protocol.c
dlls/ws2_32/tests/protocol.c
+58
-6
No files found.
dlls/ws2_32/socket.c
View file @
1d1faa02
...
@@ -191,6 +191,16 @@ static const GUID ProviderIdIPX = { 0x11058240, 0xbe47, 0x11cf,
...
@@ -191,6 +191,16 @@ static const GUID ProviderIdIPX = { 0x11058240, 0xbe47, 0x11cf,
static
const
GUID
ProviderIdSPX
=
{
0x11058241
,
0xbe47
,
0x11cf
,
static
const
GUID
ProviderIdSPX
=
{
0x11058241
,
0xbe47
,
0x11cf
,
{
0x95
,
0xc8
,
0x00
,
0x80
,
0x5f
,
0x48
,
0xa1
,
0x92
}
};
{
0x95
,
0xc8
,
0x00
,
0x80
,
0x5f
,
0x48
,
0xa1
,
0x92
}
};
static
const
INT
valid_protocols
[]
=
{
WS_IPPROTO_TCP
,
WS_IPPROTO_UDP
,
NSPROTO_IPX
,
NSPROTO_SPX
,
NSPROTO_SPXII
,
0
};
#if defined(IP_UNICAST_IF) && defined(SO_ATTACH_FILTER)
#if defined(IP_UNICAST_IF) && defined(SO_ATTACH_FILTER)
# define LINUX_BOUND_IF
# define LINUX_BOUND_IF
struct
interface_filter
{
struct
interface_filter
{
...
@@ -1259,6 +1269,14 @@ static inline BOOL supported_pf(int pf)
...
@@ -1259,6 +1269,14 @@ static inline BOOL supported_pf(int pf)
}
}
}
}
static
inline
BOOL
supported_protocol
(
int
protocol
)
{
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
valid_protocols
)
/
sizeof
(
valid_protocols
[
0
]);
i
++
)
if
(
protocol
==
valid_protocols
[
i
])
return
TRUE
;
return
FALSE
;
}
/**********************************************************************/
/**********************************************************************/
...
@@ -1665,11 +1683,10 @@ static INT WS_EnterSingleProtocolA( INT protocol, WSAPROTOCOL_INFOA* info )
...
@@ -1665,11 +1683,10 @@ static INT WS_EnterSingleProtocolA( INT protocol, WSAPROTOCOL_INFOA* info )
return
ret
;
return
ret
;
}
}
static
INT
WS_EnumProtocols
(
BOOL
unicode
,
LPINT
protocols
,
LPWSAPROTOCOL_INFOW
buffer
,
LPDWORD
len
)
static
INT
WS_EnumProtocols
(
BOOL
unicode
,
const
INT
*
protocols
,
LPWSAPROTOCOL_INFOW
buffer
,
LPDWORD
len
)
{
{
INT
i
=
0
;
INT
i
=
0
,
items
=
0
;
DWORD
size
=
0
;
DWORD
size
=
0
;
INT
local
[]
=
{
WS_IPPROTO_TCP
,
WS_IPPROTO_UDP
,
NSPROTO_IPX
,
NSPROTO_SPX
,
NSPROTO_SPXII
,
0
};
union
_info
union
_info
{
{
LPWSAPROTOCOL_INFOA
a
;
LPWSAPROTOCOL_INFOA
a
;
...
@@ -1677,11 +1694,15 @@ static INT WS_EnumProtocols( BOOL unicode, LPINT protocols, LPWSAPROTOCOL_INFOW
...
@@ -1677,11 +1694,15 @@ static INT WS_EnumProtocols( BOOL unicode, LPINT protocols, LPWSAPROTOCOL_INFOW
}
info
;
}
info
;
info
.
w
=
buffer
;
info
.
w
=
buffer
;
if
(
!
protocols
)
protocols
=
local
;
if
(
!
protocols
)
protocols
=
valid_protocols
;
while
(
protocols
[
i
])
i
++
;
while
(
protocols
[
i
])
{
if
(
supported_protocol
(
protocols
[
i
++
]))
items
++
;
}
size
=
i
*
(
unicode
?
sizeof
(
WSAPROTOCOL_INFOW
)
:
sizeof
(
WSAPROTOCOL_INFOA
));
size
=
i
tems
*
(
unicode
?
sizeof
(
WSAPROTOCOL_INFOW
)
:
sizeof
(
WSAPROTOCOL_INFOA
));
if
(
*
len
<
size
||
!
buffer
)
if
(
*
len
<
size
||
!
buffer
)
{
{
...
@@ -1690,20 +1711,20 @@ static INT WS_EnumProtocols( BOOL unicode, LPINT protocols, LPWSAPROTOCOL_INFOW
...
@@ -1690,20 +1711,20 @@ static INT WS_EnumProtocols( BOOL unicode, LPINT protocols, LPWSAPROTOCOL_INFOW
return
SOCKET_ERROR
;
return
SOCKET_ERROR
;
}
}
for
(
i
=
0
;
protocols
[
i
];
i
++
)
for
(
i
=
items
=
0
;
protocols
[
i
];
i
++
)
{
{
if
(
unicode
)
if
(
unicode
)
{
{
if
(
WS_EnterSingleProtocolW
(
protocols
[
i
],
&
info
.
w
[
i
]
)
=
=
SOCKET_ERROR
)
if
(
WS_EnterSingleProtocolW
(
protocols
[
i
],
&
info
.
w
[
i
tems
]
)
!
=
SOCKET_ERROR
)
break
;
items
++
;
}
}
else
else
{
{
if
(
WS_EnterSingleProtocolA
(
protocols
[
i
],
&
info
.
a
[
i
]
)
=
=
SOCKET_ERROR
)
if
(
WS_EnterSingleProtocolA
(
protocols
[
i
],
&
info
.
a
[
i
tems
]
)
!
=
SOCKET_ERROR
)
break
;
items
++
;
}
}
}
}
return
i
;
return
i
tems
;
}
}
/**************************************************************************
/**************************************************************************
...
...
dlls/ws2_32/tests/protocol.c
View file @
1d1faa02
...
@@ -60,9 +60,10 @@ static void test_service_flags(int family, int version, int socktype, int protoc
...
@@ -60,9 +60,10 @@ static void test_service_flags(int family, int version, int socktype, int protoc
static
void
test_WSAEnumProtocolsA
(
void
)
static
void
test_WSAEnumProtocolsA
(
void
)
{
{
INT
ret
;
INT
ret
,
i
,
j
,
found
;
DWORD
len
=
0
,
error
;
DWORD
len
=
0
,
error
;
WSAPROTOCOL_INFOA
info
,
*
buffer
;
WSAPROTOCOL_INFOA
info
,
*
buffer
;
INT
ptest
[]
=
{
0xdead
,
IPPROTO_TCP
,
0xcafe
,
IPPROTO_UDP
,
0xbeef
,
0
};
ret
=
WSAEnumProtocolsA
(
NULL
,
NULL
,
&
len
);
ret
=
WSAEnumProtocolsA
(
NULL
,
NULL
,
&
len
);
ok
(
ret
==
SOCKET_ERROR
,
"WSAEnumProtocolsA() succeeded unexpectedly
\n
"
);
ok
(
ret
==
SOCKET_ERROR
,
"WSAEnumProtocolsA() succeeded unexpectedly
\n
"
);
...
@@ -80,8 +81,6 @@ static void test_WSAEnumProtocolsA(void)
...
@@ -80,8 +81,6 @@ static void test_WSAEnumProtocolsA(void)
if
(
buffer
)
if
(
buffer
)
{
{
INT
i
;
ret
=
WSAEnumProtocolsA
(
NULL
,
buffer
,
&
len
);
ret
=
WSAEnumProtocolsA
(
NULL
,
buffer
,
&
len
);
ok
(
ret
!=
SOCKET_ERROR
,
"WSAEnumProtocolsA() failed unexpectedly: %d
\n
"
,
ok
(
ret
!=
SOCKET_ERROR
,
"WSAEnumProtocolsA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
WSAGetLastError
()
);
...
@@ -96,13 +95,41 @@ static void test_WSAEnumProtocolsA(void)
...
@@ -96,13 +95,41 @@ static void test_WSAEnumProtocolsA(void)
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
}
/* Test invalid protocols in the list */
ret
=
WSAEnumProtocolsA
(
ptest
,
NULL
,
&
len
);
ok
(
ret
==
SOCKET_ERROR
,
"WSAEnumProtocolsA() succeeded unexpectedly
\n
"
);
error
=
WSAGetLastError
();
ok
(
error
==
WSAENOBUFS
,
"Expected 10055, received %d
\n
"
,
error
);
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
if
(
buffer
)
{
ret
=
WSAEnumProtocolsA
(
ptest
,
buffer
,
&
len
);
ok
(
ret
!=
SOCKET_ERROR
,
"WSAEnumProtocolsA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
ok
(
ret
>=
2
,
"Expected at least 2 items, received %d
\n
"
,
ret
);
for
(
i
=
found
=
0
;
i
<
ret
;
i
++
)
for
(
j
=
0
;
j
<
sizeof
(
ptest
)
/
sizeof
(
ptest
[
0
]);
j
++
)
if
(
buffer
[
i
].
iProtocol
==
ptest
[
j
])
{
found
|=
1
<<
j
;
break
;
}
ok
(
found
==
0x0A
,
"Expected 2 bits represented as 0xA, received 0x%x
\n
"
,
found
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
}
}
static
void
test_WSAEnumProtocolsW
(
void
)
static
void
test_WSAEnumProtocolsW
(
void
)
{
{
INT
ret
;
INT
ret
,
i
,
j
,
found
;
DWORD
len
=
0
,
error
;
DWORD
len
=
0
,
error
;
WSAPROTOCOL_INFOW
info
,
*
buffer
;
WSAPROTOCOL_INFOW
info
,
*
buffer
;
INT
ptest
[]
=
{
0xdead
,
IPPROTO_TCP
,
0xcafe
,
IPPROTO_UDP
,
0xbeef
,
0
};
ret
=
WSAEnumProtocolsW
(
NULL
,
NULL
,
&
len
);
ret
=
WSAEnumProtocolsW
(
NULL
,
NULL
,
&
len
);
ok
(
ret
==
SOCKET_ERROR
,
"WSAEnumProtocolsW() succeeded unexpectedly
\n
"
);
ok
(
ret
==
SOCKET_ERROR
,
"WSAEnumProtocolsW() succeeded unexpectedly
\n
"
);
...
@@ -120,8 +147,6 @@ static void test_WSAEnumProtocolsW(void)
...
@@ -120,8 +147,6 @@ static void test_WSAEnumProtocolsW(void)
if
(
buffer
)
if
(
buffer
)
{
{
INT
i
;
ret
=
WSAEnumProtocolsW
(
NULL
,
buffer
,
&
len
);
ret
=
WSAEnumProtocolsW
(
NULL
,
buffer
,
&
len
);
ok
(
ret
!=
SOCKET_ERROR
,
"WSAEnumProtocolsW() failed unexpectedly: %d
\n
"
,
ok
(
ret
!=
SOCKET_ERROR
,
"WSAEnumProtocolsW() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
WSAGetLastError
()
);
...
@@ -136,6 +161,33 @@ static void test_WSAEnumProtocolsW(void)
...
@@ -136,6 +161,33 @@ static void test_WSAEnumProtocolsW(void)
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
}
/* Test invalid protocols in the list */
ret
=
WSAEnumProtocolsW
(
ptest
,
NULL
,
&
len
);
ok
(
ret
==
SOCKET_ERROR
,
"WSAEnumProtocolsW() succeeded unexpectedly
\n
"
);
error
=
WSAGetLastError
();
ok
(
error
==
WSAENOBUFS
,
"Expected 10055, received %d
\n
"
,
error
);
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
if
(
buffer
)
{
ret
=
WSAEnumProtocolsW
(
ptest
,
buffer
,
&
len
);
ok
(
ret
!=
SOCKET_ERROR
,
"WSAEnumProtocolsW() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
ok
(
ret
>=
2
,
"Expected at least 2 items, received %d
\n
"
,
ret
);
for
(
i
=
found
=
0
;
i
<
ret
;
i
++
)
for
(
j
=
0
;
j
<
sizeof
(
ptest
)
/
sizeof
(
ptest
[
0
]);
j
++
)
if
(
buffer
[
i
].
iProtocol
==
ptest
[
j
])
{
found
|=
1
<<
j
;
break
;
}
ok
(
found
==
0x0A
,
"Expected 2 bits represented as 0xA, received 0x%x
\n
"
,
found
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
}
}
START_TEST
(
protocol
)
START_TEST
(
protocol
)
...
...
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