Commit cd458db6 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Tighten SO{RCV,SND}TIMEO check

We can check the size of the return value too.
parent ab70df53
......@@ -354,7 +354,7 @@ struct timeval tv = { 1, 0 };
if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv) == 0) {
socklen_t l = sizeof tv;
if (getsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, &tv, &l) == 0) {
return 0;
return (l != sizeof tv);
}
}
return 1;
......@@ -379,7 +379,7 @@ struct timeval tv = { 1, 0 };
if (setsockopt(sd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv) == 0) {
socklen_t l = sizeof tv;
if (getsockopt(sd, SOL_SOCKET, SO_SNDTIMEO, &tv, &l) == 0) {
return 0;
return (l != sizeof tv);
}
}
return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment