diff options
author | Xi Wang <xi.wang@gmail.com> | 2012-08-26 12:47:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-31 15:55:37 -0400 |
commit | fc61b928dc4d72176cf4bd4d30bf1d22e599aefc (patch) | |
tree | 6ae17685b8c9657293670d38f4703a4c597a3523 /net/unix | |
parent | 46b66d7077b89fb4917ceef19b3f7dd86055c94a (diff) |
af_unix: fix shutdown parameter checking
Return -EINVAL rather than 0 given an invalid "mode" parameter.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/unix')
-rw-r--r-- | net/unix/af_unix.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index c5ee4ff61364..8a84ab64cafd 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -2060,10 +2060,14 @@ static int unix_shutdown(struct socket *sock, int mode) | |||
2060 | struct sock *sk = sock->sk; | 2060 | struct sock *sk = sock->sk; |
2061 | struct sock *other; | 2061 | struct sock *other; |
2062 | 2062 | ||
2063 | mode = (mode+1)&(RCV_SHUTDOWN|SEND_SHUTDOWN); | 2063 | if (mode < SHUT_RD || mode > SHUT_RDWR) |
2064 | 2064 | return -EINVAL; | |
2065 | if (!mode) | 2065 | /* This maps: |
2066 | return 0; | 2066 | * SHUT_RD (0) -> RCV_SHUTDOWN (1) |
2067 | * SHUT_WR (1) -> SEND_SHUTDOWN (2) | ||
2068 | * SHUT_RDWR (2) -> SHUTDOWN_MASK (3) | ||
2069 | */ | ||
2070 | ++mode; | ||
2067 | 2071 | ||
2068 | unix_state_lock(sk); | 2072 | unix_state_lock(sk); |
2069 | sk->sk_shutdown |= mode; | 2073 | sk->sk_shutdown |= mode; |