Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
4a94ce63
Commit
4a94ce63
authored
May 05, 2019
by
Minun Dragonation
Browse files
fix bugs for optlen output on size not big enough for timeout events
parent
82252440
Changes
1
Hide whitespace changes
Inline
Side-by-side
sockcompat.c
View file @
4a94ce63
...
@@ -191,11 +191,16 @@ int win32_connect(SOCKET sockfd, const struct sockaddr *addr, socklen_t addrlen)
...
@@ -191,11 +191,16 @@ int win32_connect(SOCKET sockfd, const struct sockaddr *addr, socklen_t addrlen)
int
win32_getsockopt
(
SOCKET
sockfd
,
int
level
,
int
optname
,
void
*
optval
,
socklen_t
*
optlen
)
{
int
win32_getsockopt
(
SOCKET
sockfd
,
int
level
,
int
optname
,
void
*
optval
,
socklen_t
*
optlen
)
{
int
ret
=
0
;
int
ret
=
0
;
if
((
level
==
SOL_SOCKET
)
&&
((
optname
==
SO_RCVTIMEO
)
||
(
optname
==
SO_SNDTIMEO
)))
{
if
((
level
==
SOL_SOCKET
)
&&
((
optname
==
SO_RCVTIMEO
)
||
(
optname
==
SO_SNDTIMEO
)))
{
struct
timeval
*
tv
=
(
struct
timeval
*
)
optval
;
if
(
*
optlen
>=
sizeof
(
struct
timeval
))
{
DWORD
timeout
=
0
;
socklen_t
dwlen
=
0
;
struct
timeval
*
tv
=
(
struct
timeval
*
)
optval
;
ret
=
getsockopt
(
sockfd
,
level
,
optname
,
(
char
*
)
&
timeout
,
&
dwlen
);
DWORD
timeout
=
0
;
tv
->
tv_sec
=
timeout
/
1000
;
socklen_t
dwlen
=
0
;
tv
->
tv_usec
=
timeout
*
1000
;
ret
=
getsockopt
(
sockfd
,
level
,
optname
,
(
char
*
)
&
timeout
,
&
dwlen
);
tv
->
tv_sec
=
timeout
/
1000
;
tv
->
tv_usec
=
timeout
*
1000
;
}
else
{
ret
=
WSAEFAULT
;
}
*
optlen
=
sizeof
(
struct
timeval
);
*
optlen
=
sizeof
(
struct
timeval
);
}
else
{
}
else
{
ret
=
getsockopt
(
sockfd
,
level
,
optname
,
(
char
*
)
optval
,
optlen
);
ret
=
getsockopt
(
sockfd
,
level
,
optname
,
(
char
*
)
optval
,
optlen
);
...
...
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