diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2005-09-06 17:51:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-09-06 17:51:39 -0400 |
commit | 9261c9b042547d01eeb206cf0e21ce72832245ec (patch) | |
tree | e6dbce47404e1d40dff0fb5814463d89370a6642 /net/core | |
parent | fe2d5295a11e2ab2d6f4e7ea074816000b32eba3 (diff) |
[NET]: Make sure l_linger is unsigned to avoid negative timeouts
One of my x86_64 (linux 2.6.13) server log is filled with :
schedule_timeout: wrong timeout value ffffffffffffff06 from ffffffff802e63ca
schedule_timeout: wrong timeout value ffffffffffffff06 from ffffffff802e63ca
schedule_timeout: wrong timeout value ffffffffffffff06 from ffffffff802e63ca
schedule_timeout: wrong timeout value ffffffffffffff06 from ffffffff802e63ca
schedule_timeout: wrong timeout value ffffffffffffff06 from ffffffff802e63ca
This is because some application does a
struct linger li;
li.l_onoff = 1;
li.l_linger = -1;
setsockopt(sock, SOL_SOCKET, SO_LINGER, &li, sizeof(li));
And unfortunatly l_linger is defined as a 'signed int' in
include/linux/socket.h:
struct linger {
int l_onoff; /* Linger active */
int l_linger; /* How long to linger for */
};
I dont know if it's safe to change l_linger to 'unsigned int' in the
include file (It might be defined as int in ABI specs)
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/sock.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index c13594579bfb..b32b1815ae5a 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -341,11 +341,11 @@ set_rcvbuf: | |||
341 | sock_reset_flag(sk, SOCK_LINGER); | 341 | sock_reset_flag(sk, SOCK_LINGER); |
342 | else { | 342 | else { |
343 | #if (BITS_PER_LONG == 32) | 343 | #if (BITS_PER_LONG == 32) |
344 | if (ling.l_linger >= MAX_SCHEDULE_TIMEOUT/HZ) | 344 | if ((unsigned int)ling.l_linger >= MAX_SCHEDULE_TIMEOUT/HZ) |
345 | sk->sk_lingertime = MAX_SCHEDULE_TIMEOUT; | 345 | sk->sk_lingertime = MAX_SCHEDULE_TIMEOUT; |
346 | else | 346 | else |
347 | #endif | 347 | #endif |
348 | sk->sk_lingertime = ling.l_linger * HZ; | 348 | sk->sk_lingertime = (unsigned int)ling.l_linger * HZ; |
349 | sock_set_flag(sk, SOCK_LINGER); | 349 | sock_set_flag(sk, SOCK_LINGER); |
350 | } | 350 | } |
351 | break; | 351 | break; |