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
9e3a3f46
Commit
9e3a3f46
authored
Apr 27, 2015
by
Jacek Caban
Committed by
Alexandre Julliard
Apr 28, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Avoid overflows in get_rcvsnd_timeo.
parent
d15ca4ed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
18 deletions
+21
-18
socket.c
dlls/ws2_32/socket.c
+21
-18
No files found.
dlls/ws2_32/socket.c
View file @
9e3a3f46
...
...
@@ -1251,30 +1251,28 @@ static char *strdup_lower(const char *str)
/* Utility: get the SO_RCVTIMEO or SO_SNDTIMEO socket option
* from an fd and return the value converted to milli seconds
* or
-1
if there is an infinite time out */
static
inline
int
get_rcvsnd_timeo
(
int
fd
,
int
optname
)
* or
0
if there is an infinite time out */
static
inline
INT64
get_rcvsnd_timeo
(
int
fd
,
int
optname
)
{
struct
timeval
tv
;
socklen_t
len
=
sizeof
(
tv
);
int
ret
=
getsockopt
(
fd
,
SOL_SOCKET
,
optname
,
&
tv
,
&
len
);
if
(
ret
>=
0
)
ret
=
tv
.
tv_sec
*
1000
+
tv
.
tv_usec
/
1000
;
if
(
ret
<=
0
)
/* tv == {0,0} means infinite time out */
return
-
1
;
return
ret
;
int
res
=
getsockopt
(
fd
,
SOL_SOCKET
,
optname
,
&
tv
,
&
len
);
if
(
res
<
0
)
return
0
;
return
(
UINT64
)
tv
.
tv_sec
*
1000
+
tv
.
tv_usec
/
1000
;
}
/* macro wrappers for portability */
#ifdef SO_RCVTIMEO
#define GET_RCVTIMEO(fd) get_rcvsnd_timeo( (fd), SO_RCVTIMEO)
#else
#define GET_RCVTIMEO(fd) (
-1
)
#define GET_RCVTIMEO(fd) (
0
)
#endif
#ifdef SO_SNDTIMEO
#define GET_SNDTIMEO(fd) get_rcvsnd_timeo( (fd), SO_SNDTIMEO)
#else
#define GET_SNDTIMEO(fd) (
-1
)
#define GET_SNDTIMEO(fd) (
0
)
#endif
/* utility: given an fd, will block until one of the events occurs */
...
...
@@ -5076,18 +5074,20 @@ static int WS2_sendto( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
while
(
wsa
->
first_iovec
<
wsa
->
n_iovecs
)
{
struct
pollfd
pfd
;
int
timeout
=
GET_SNDTIMEO
(
fd
);
int
poll_timeout
=
-
1
;
INT64
timeout
=
GET_SNDTIMEO
(
fd
);
if
(
timeout
!=
-
1
)
if
(
timeout
)
{
timeout
-=
GetTickCount
()
-
timeout_start
;
if
(
timeout
<
0
)
timeout
=
0
;
if
(
timeout
<
0
)
poll_timeout
=
0
;
else
poll_timeout
=
timeout
<=
INT_MAX
?
timeout
:
INT_MAX
;
}
pfd
.
fd
=
fd
;
pfd
.
events
=
POLLOUT
;
if
(
!
timeout
||
!
poll
(
&
pfd
,
1
,
timeout
))
if
(
!
poll_timeout
||
!
poll
(
&
pfd
,
1
,
poll_
timeout
))
{
err
=
WSAETIMEDOUT
;
goto
error
;
/* msdn says a timeout in send is fatal */
...
...
@@ -7130,18 +7130,21 @@ static int WS2_recv_base( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
if
(
is_blocking
)
{
struct
pollfd
pfd
;
int
timeout
=
GET_RCVTIMEO
(
fd
);
if
(
timeout
!=
-
1
)
int
poll_timeout
=
-
1
;
INT64
timeout
=
GET_RCVTIMEO
(
fd
);
if
(
timeout
)
{
timeout
-=
GetTickCount
()
-
timeout_start
;
if
(
timeout
<
0
)
timeout
=
0
;
if
(
timeout
<
0
)
poll_timeout
=
0
;
else
poll_timeout
=
timeout
<=
INT_MAX
?
timeout
:
INT_MAX
;
}
pfd
.
fd
=
fd
;
pfd
.
events
=
POLLIN
;
if
(
*
lpFlags
&
WS_MSG_OOB
)
pfd
.
events
|=
POLLPRI
;
if
(
!
timeout
||
!
poll
(
&
pfd
,
1
,
timeout
))
if
(
!
poll_timeout
||
!
poll
(
&
pfd
,
1
,
poll_
timeout
))
{
err
=
WSAETIMEDOUT
;
/* a timeout is not fatal */
...
...
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