Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-fonts
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
Aleksandr Isakov
wine-fonts
Commits
4cbfe4e1
Commit
4cbfe4e1
authored
Sep 20, 2010
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Fail when select is called with an invalid fd.
Based on a patch by Vincent Povirk.
parent
3d6a57a4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
7 deletions
+26
-7
socket.c
dlls/ws2_32/socket.c
+23
-4
sock.c
dlls/ws2_32/tests/sock.c
+3
-3
No files found.
dlls/ws2_32/socket.c
View file @
4cbfe4e1
...
...
@@ -3087,11 +3087,16 @@ static struct pollfd *fd_sets_to_poll( const WS_fd_set *readfds, const WS_fd_set
if
(
exceptfds
)
count
+=
exceptfds
->
fd_count
;
*
count_ptr
=
count
;
if
(
!
count
)
return
NULL
;
if
(
!
(
fds
=
HeapAlloc
(
GetProcessHeap
(),
0
,
count
*
sizeof
(
fds
[
0
]))))
return
NULL
;
if
(
!
(
fds
=
HeapAlloc
(
GetProcessHeap
(),
0
,
count
*
sizeof
(
fds
[
0
]))))
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
NULL
;
}
if
(
readfds
)
for
(
i
=
0
;
i
<
readfds
->
fd_count
;
i
++
,
j
++
)
{
fds
[
j
].
fd
=
get_sock_fd
(
readfds
->
fd_array
[
i
],
FILE_READ_DATA
,
NULL
);
if
(
fds
[
j
].
fd
==
-
1
)
goto
failed
;
fds
[
j
].
events
=
POLLIN
;
fds
[
j
].
revents
=
0
;
}
...
...
@@ -3099,6 +3104,7 @@ static struct pollfd *fd_sets_to_poll( const WS_fd_set *readfds, const WS_fd_set
for
(
i
=
0
;
i
<
writefds
->
fd_count
;
i
++
,
j
++
)
{
fds
[
j
].
fd
=
get_sock_fd
(
writefds
->
fd_array
[
i
],
FILE_WRITE_DATA
,
NULL
);
if
(
fds
[
j
].
fd
==
-
1
)
goto
failed
;
fds
[
j
].
events
=
POLLOUT
;
fds
[
j
].
revents
=
0
;
}
...
...
@@ -3106,10 +3112,26 @@ static struct pollfd *fd_sets_to_poll( const WS_fd_set *readfds, const WS_fd_set
for
(
i
=
0
;
i
<
exceptfds
->
fd_count
;
i
++
,
j
++
)
{
fds
[
j
].
fd
=
get_sock_fd
(
exceptfds
->
fd_array
[
i
],
0
,
NULL
);
if
(
fds
[
j
].
fd
==
-
1
)
goto
failed
;
fds
[
j
].
events
=
POLLHUP
;
fds
[
j
].
revents
=
0
;
}
return
fds
;
failed:
count
=
j
;
j
=
0
;
if
(
readfds
)
for
(
i
=
0
;
i
<
readfds
->
fd_count
&&
j
<
count
;
i
++
,
j
++
)
release_sock_fd
(
readfds
->
fd_array
[
i
],
fds
[
j
].
fd
);
if
(
writefds
)
for
(
i
=
0
;
i
<
writefds
->
fd_count
&&
j
<
count
;
i
++
,
j
++
)
release_sock_fd
(
writefds
->
fd_array
[
i
],
fds
[
j
].
fd
);
if
(
exceptfds
)
for
(
i
=
0
;
i
<
exceptfds
->
fd_count
&&
j
<
count
;
i
++
,
j
++
)
release_sock_fd
(
exceptfds
->
fd_array
[
i
],
fds
[
j
].
fd
);
HeapFree
(
GetProcessHeap
(),
0
,
fds
);
return
NULL
;
}
/* release the file descriptor obtained in fd_sets_to_poll */
...
...
@@ -3188,10 +3210,7 @@ int WINAPI WS_select(int nfds, WS_fd_set *ws_readfds,
ws_readfds
,
ws_writefds
,
ws_exceptfds
,
ws_timeout
);
if
(
!
(
pollfds
=
fd_sets_to_poll
(
ws_readfds
,
ws_writefds
,
ws_exceptfds
,
&
count
))
&&
count
)
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
SOCKET_ERROR
;
}
if
(
ws_timeout
)
{
...
...
dlls/ws2_32/tests/sock.c
View file @
4cbfe4e1
...
...
@@ -1946,7 +1946,7 @@ static void test_select(void)
FD_SET
(
INVALID_SOCKET
,
&
readfds
);
SetLastError
(
0
);
ret
=
select
(
maxfd
+
1
,
&
readfds
,
&
writefds
,
&
exceptfds
,
&
select_timeout
);
todo_wine
ok
(
(
ret
==
SOCKET_ERROR
),
"expected SOCKET_ERROR, got %i
\n
"
,
ret
);
ok
(
(
ret
==
SOCKET_ERROR
),
"expected SOCKET_ERROR, got %i
\n
"
,
ret
);
ok
(
GetLastError
()
==
WSAENOTSOCK
,
"expected WSAENOTSOCK, got %i
\n
"
,
ret
);
ok
(
!
FD_ISSET
(
fdRead
,
&
readfds
),
"FD should not be set
\n
"
);
...
...
@@ -1954,7 +1954,7 @@ static void test_select(void)
FD_SET
(
INVALID_SOCKET
,
&
writefds
);
SetLastError
(
0
);
ret
=
select
(
maxfd
+
1
,
&
readfds
,
&
writefds
,
&
exceptfds
,
&
select_timeout
);
todo_wine
ok
(
(
ret
==
SOCKET_ERROR
),
"expected SOCKET_ERROR, got %i
\n
"
,
ret
);
ok
(
(
ret
==
SOCKET_ERROR
),
"expected SOCKET_ERROR, got %i
\n
"
,
ret
);
ok
(
GetLastError
()
==
WSAENOTSOCK
,
"expected WSAENOTSOCK, got %i
\n
"
,
ret
);
ok
(
!
FD_ISSET
(
fdRead
,
&
writefds
),
"FD should not be set
\n
"
);
...
...
@@ -1962,7 +1962,7 @@ static void test_select(void)
FD_SET
(
INVALID_SOCKET
,
&
exceptfds
);
SetLastError
(
0
);
ret
=
select
(
maxfd
+
1
,
&
readfds
,
&
writefds
,
&
exceptfds
,
&
select_timeout
);
todo_wine
ok
(
(
ret
==
SOCKET_ERROR
),
"expected SOCKET_ERROR, got %i
\n
"
,
ret
);
ok
(
(
ret
==
SOCKET_ERROR
),
"expected SOCKET_ERROR, got %i
\n
"
,
ret
);
ok
(
GetLastError
()
==
WSAENOTSOCK
,
"expected WSAENOTSOCK, got %i
\n
"
,
ret
);
ok
(
!
FD_ISSET
(
fdRead
,
&
exceptfds
),
"FD should not be set
\n
"
);
}
...
...
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