From 82eb51ee05dfe3a03089c811797da73e4ed7e3e9 Mon Sep 17 00:00:00 2001 From: kleink Date: Mon, 27 Apr 1998 13:31:45 +0000 Subject: [PATCH] In soshutdown(), decouple the evaluation of the `how' argument from FREAD and FWRITE; use SHUT_{RD,WR,RDWR} instead. Also, return EINVAL if `how' is invalid. --- sys/kern/uipc_socket.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index c8a99a2a998d..e19ccf2b2fb2 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.33 1998/04/25 17:35:18 matt Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.34 1998/04/27 13:31:45 kleink Exp $ */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993 @@ -809,15 +809,17 @@ release: int soshutdown(so, how) - register struct socket *so; - register int how; + struct socket *so; + int how; { - register struct protosw *pr = so->so_proto; + struct protosw *pr = so->so_proto; - how++; - if (how & FREAD) + if (!(how == SHUT_RD || how == SHUT_WR || how == SHUT_RDWR)) + return (EINVAL); + + if (how == SHUT_RD || how == SHUT_RDWR) sorflush(so); - if (how & FWRITE) + if (how == SHUT_WR || how == SHUT_RDWR) return (*pr->pr_usrreq)(so, PRU_SHUTDOWN, (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0); return (0);