1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

only allow accept filter modifications on listening sockets

Submitted by: ps
This commit is contained in:
Alfred Perlstein 2000-07-20 12:17:17 +00:00
parent 85f5e7f098
commit f408896444
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=63646

View File

@ -998,6 +998,12 @@ do_setopt_accept_filter(so, sopt)
struct so_accf *af = so->so_accf;
int error = 0;
/* do not set/remove accept filters on non listen sockets */
if ((so->so_options & SO_ACCEPTCONN) == 0) {
error = EINVAL;
goto out;
}
/* removing the filter */
if (sopt == NULL) {
if (af != NULL) {
@ -1289,6 +1295,8 @@ sogetopt(so, sopt)
} else {
switch (sopt->sopt_name) {
case SO_ACCEPTFILTER:
if ((so->so_options & SO_ACCEPTCONN) == 0)
return (EINVAL);
MALLOC(afap, struct accept_filter_arg *, sizeof(*afap),
M_TEMP, M_WAITOK);
bzero(afap, sizeof(*afap));