Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.235.2.7 retrieving revision 1.258 diff -u -p -r1.235.2.7 -r1.258 --- src/sys/kern/uipc_socket.c 2017/08/28 17:53:07 1.235.2.7 +++ src/sys/kern/uipc_socket.c 2018/01/01 00:45:12 1.258 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.235.2.7 2017/08/28 17:53:07 skrll Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.258 2018/01/01 00:45:12 christos Exp $ */ /*- * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.235.2.7 2017/08/28 17:53:07 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.258 2018/01/01 00:45:12 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -2109,7 +2109,9 @@ sockopt_set(struct sockopt *sopt, const return error; } - KASSERT(sopt->sopt_size == len); + if (sopt->sopt_size < len) + return EINVAL; + memcpy(sopt->sopt_data, buf, len); return 0; } @@ -2169,7 +2171,9 @@ sockopt_setmbuf(struct sockopt *sopt, st return error; } - KASSERT(sopt->sopt_size == len); + if (sopt->sopt_size < len) + return EINVAL; + m_copydata(m, 0, len, sopt->sopt_data); m_freem(m); @@ -2319,12 +2323,26 @@ filt_solisten(struct knote *kn, long hin return rv; } -static const struct filterops solisten_filtops = - { 1, NULL, filt_sordetach, filt_solisten }; -static const struct filterops soread_filtops = - { 1, NULL, filt_sordetach, filt_soread }; -static const struct filterops sowrite_filtops = - { 1, NULL, filt_sowdetach, filt_sowrite }; +static const struct filterops solisten_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_sordetach, + .f_event = filt_solisten, +}; + +static const struct filterops soread_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_sordetach, + .f_event = filt_soread, +}; + +static const struct filterops sowrite_filtops = { + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_sowdetach, + .f_event = filt_sowrite, +}; int soo_kqfilter(struct file *fp, struct knote *kn)