Page MenuHomeFreeBSD

D43412.id132836.diff
No OneTemporary

D43412.id132836.diff

diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -2964,14 +2964,11 @@
}
int
-soshutdown(struct socket *so, int how)
+soshutdown(struct socket *so, enum shutdown_how how)
{
struct protosw *pr;
int error, soerror_enotconn;
- if (!(how == SHUT_RD || how == SHUT_WR || how == SHUT_RDWR))
- return (EINVAL);
-
soerror_enotconn = 0;
SOCK_LOCK(so);
if ((so->so_state &
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1172,6 +1172,9 @@
struct file *fp;
int error;
+ if (__predict_false(how < SHUT_RD || how > SHUT_RDWR))
+ return (EINVAL);
+
AUDIT_ARG_FD(s);
error = getsock(td, s, &cap_shutdown_rights, &fp);
if (error == 0) {
diff --git a/sys/sys/socket.h b/sys/sys/socket.h
--- a/sys/sys/socket.h
+++ b/sys/sys/socket.h
@@ -627,9 +627,11 @@
/*
* howto arguments for shutdown(2), specified by Posix.1g.
*/
-#define SHUT_RD 0 /* shut down the reading side */
-#define SHUT_WR 1 /* shut down the writing side */
-#define SHUT_RDWR 2 /* shut down both sides */
+enum shutdown_how {
+ SHUT_RD = 0, /* shut down the reading side */
+ SHUT_WR, /* shut down the writing side */
+ SHUT_RDWR /* shut down both sides */
+};
#if __BSD_VISIBLE
/* for SCTP */
diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
--- a/sys/sys/socketvar.h
+++ b/sys/sys/socketvar.h
@@ -434,6 +434,7 @@
struct sockaddr;
struct ucred;
struct uio;
+enum shutdown_how;
/* Return values for socket upcalls. */
#define SU_OK 0
@@ -512,7 +513,7 @@
int sosend_generic(struct socket *so, struct sockaddr *addr,
struct uio *uio, struct mbuf *top, struct mbuf *control,
int flags, struct thread *td);
-int soshutdown(struct socket *so, int how);
+int soshutdown(struct socket *so, enum shutdown_how);
void soupcall_clear(struct socket *, sb_which);
void soupcall_set(struct socket *, sb_which, so_upcall_t, void *);
void solisten_upcall_set(struct socket *, so_upcall_t, void *);

File Metadata

Mime Type
text/plain
Expires
Sun, Sep 29, 7:37 AM (2 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
12985685
Default Alt Text
D43412.id132836.diff (2 KB)

Event Timeline