Skip to content

Commit

Permalink
[TIPC]: Add argument validation for shutdown()
Browse files Browse the repository at this point in the history
This patch validates that the "how" argument to shutdown()
is SHUT_RDWR, since this is the only form that TIPC supports.

Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Allan Stephens authored and David S. Miller committed Mar 6, 2008
1 parent 8c86965 commit e247a8f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/tipc/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ static int accept(struct socket *sock, struct socket *newsock, int flags)
/**
* shutdown - shutdown socket connection
* @sock: socket structure
* @how: direction to close (unused; always treated as read + write)
* @how: direction to close (must be SHUT_RDWR)
*
* Terminates connection (if necessary), then purges socket's receive queue.
*
Expand All @@ -1432,7 +1432,8 @@ static int shutdown(struct socket *sock, int how)
struct sk_buff *buf;
int res;

/* Could return -EINVAL for an invalid "how", but why bother? */
if (how != SHUT_RDWR)
return -EINVAL;

if (mutex_lock_interruptible(&tsock->lock))
return -ERESTARTSYS;
Expand Down

0 comments on commit e247a8f

Please sign in to comment.