From 7e66c109f220da93bb308d7951e736226d7f8691 Mon Sep 17 00:00:00 2001 From: glebius Date: Tue, 16 Oct 2018 15:57:16 +0000 Subject: [PATCH] Plug sendfile(2) on a listening socket with proper error code. Reported by: ngie Reviewed by: ngie Approved by: re (delphij) --- sys/kern/kern_sendfile.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c index 438069aa721f..50404ce57458 100644 --- a/sys/kern/kern_sendfile.c +++ b/sys/kern/kern_sendfile.c @@ -526,6 +526,8 @@ sendfile_getsock(struct thread *td, int s, struct file **sock_fp, *so = (*sock_fp)->f_data; if ((*so)->so_type != SOCK_STREAM) return (EINVAL); + if (SOLISTENING(*so)) + return (ENOTCONN); return (0); }