diff options
author | Xi Wang <xi.wang@gmail.com> | 2012-08-26 16:47:13 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-31 15:55:37 -0400 |
commit | fc61b928dc4d72176cf4bd4d30bf1d22e599aefc (patch) | |
tree | 6ae17685b8c9657293670d38f4703a4c597a3523 /net/unix/af_unix.c | |
parent | 46b66d7077b89fb4917ceef19b3f7dd86055c94a (diff) | |
download | linux-stable-fc61b928dc4d72176cf4bd4d30bf1d22e599aefc.tar.gz linux-stable-fc61b928dc4d72176cf4bd4d30bf1d22e599aefc.tar.bz2 linux-stable-fc61b928dc4d72176cf4bd4d30bf1d22e599aefc.zip |
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/af_unix.c')
-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) struct sock *sk = sock->sk; struct sock *other; - mode = (mode+1)&(RCV_SHUTDOWN|SEND_SHUTDOWN); - - if (!mode) - return 0; + if (mode < SHUT_RD || mode > SHUT_RDWR) + return -EINVAL; + /* This maps: + * SHUT_RD (0) -> RCV_SHUTDOWN (1) + * SHUT_WR (1) -> SEND_SHUTDOWN (2) + * SHUT_RDWR (2) -> SHUTDOWN_MASK (3) + */ + ++mode; unix_state_lock(sk); sk->sk_shutdown |= mode; |