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>
This commit is contained in:
parent
46b66d7077
commit
fc61b928dc
1 changed files with 8 additions and 4 deletions
|
@ -2060,10 +2060,14 @@ static int unix_shutdown(struct socket *sock, int mode)
|
||||||
struct sock *sk = sock->sk;
|
struct sock *sk = sock->sk;
|
||||||
struct sock *other;
|
struct sock *other;
|
||||||
|
|
||||||
mode = (mode+1)&(RCV_SHUTDOWN|SEND_SHUTDOWN);
|
if (mode < SHUT_RD || mode > SHUT_RDWR)
|
||||||
|
return -EINVAL;
|
||||||
if (!mode)
|
/* This maps:
|
||||||
return 0;
|
* SHUT_RD (0) -> RCV_SHUTDOWN (1)
|
||||||
|
* SHUT_WR (1) -> SEND_SHUTDOWN (2)
|
||||||
|
* SHUT_RDWR (2) -> SHUTDOWN_MASK (3)
|
||||||
|
*/
|
||||||
|
++mode;
|
||||||
|
|
||||||
unix_state_lock(sk);
|
unix_state_lock(sk);
|
||||||
sk->sk_shutdown |= mode;
|
sk->sk_shutdown |= mode;
|
||||||
|
|
Loading…
Reference in a new issue