aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/uipc_accf.c
diff options
context:
space:
mode:
authorMaxim Konovalov <maxim@FreeBSD.org>2005-06-11 11:59:48 +0000
committerMaxim Konovalov <maxim@FreeBSD.org>2005-06-11 11:59:48 +0000
commit922a5d9c2b1b2aef398492af343a38b86b5f01c7 (patch)
treecf645ec5448a6417f797787f1f7383a70a85373c /sys/kern/uipc_accf.c
parent96c111da9b955f12eea2bd6eabcdf70846019a8e (diff)
downloadsrc-922a5d9c2b1b2aef398492af343a38b86b5f01c7.tar.gz
src-922a5d9c2b1b2aef398492af343a38b86b5f01c7.zip
o setsockopt(2) cannot remove accept filter. [1]
o getsockopt(SO_ACCEPTFILTER) always returns success on listen socket even we didn't install accept filter on the socket. o Fix these bugs and add regression tests for them. Submitted by: Igor Sysoev [1] Reviewed by: alfred MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=147300
Diffstat (limited to 'sys/kern/uipc_accf.c')
-rw-r--r--sys/kern/uipc_accf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/uipc_accf.c b/sys/kern/uipc_accf.c
index 8991120a4312..4449b5bc5c68 100644
--- a/sys/kern/uipc_accf.c
+++ b/sys/kern/uipc_accf.c
@@ -176,8 +176,10 @@ do_getopt_accept_filter(struct socket *so, struct sockopt *sopt)
error = EINVAL;
goto out;
}
- if ((so->so_options & SO_ACCEPTFILTER) == 0)
+ if ((so->so_options & SO_ACCEPTFILTER) == 0) {
+ error = EINVAL;
goto out;
+ }
strcpy(afap->af_name, so->so_accf->so_accept_filter->accf_name);
if (so->so_accf->so_accept_filter_str != NULL)
strcpy(afap->af_arg, so->so_accf->so_accept_filter_str);
@@ -200,7 +202,7 @@ do_setopt_accept_filter(struct socket *so, struct sockopt *sopt)
/*
* Handle the simple delete case first.
*/
- if (sopt == NULL) {
+ if (sopt == NULL || sopt->sopt_val == NULL) {
SOCK_LOCK(so);
if ((so->so_options & SO_ACCEPTCONN) == 0) {
SOCK_UNLOCK(so);