DORMANTno replies

[PATCH 02/08] [TIPC]: Add argument validation for shutdown()

From: Stephens, Allan <hidden>
Date: 2008-02-22 19:59:27
Subsystem: networking [general], the rest, tipc network layer · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds, Jon Maloy, Tung Quang Nguyen

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 <redacted>
---
 net/tipc/socket.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 2290903..e5a6983 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1419,20 +1419,25 @@ exit:
 /**
  * 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.
  *
  * Returns 0 on success, errno otherwise
  */
 
+#ifndef SHUT_RDWR
+#define SHUT_RDWR 2
+#endif
+
 static int shutdown(struct socket *sock, int how)
 {
 	struct tipc_sock* tsock = tipc_sk(sock->sk);
 	struct sk_buff *buf;
 	int res;
 
-	/* Could return -EINVAL for an invalid "how", but why bother? */
+	if (how != SHUT_RDWR)
+		return -EINVAL;
 
 	if (down_interruptible(&tsock->sem))
 		return -ERESTARTSYS;
-- 
1.5.3.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help