Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src - npfctl: fix the confusion in the parser (0/0 case with no ...
details: https://anonhg.NetBSD.org/src/rev/4266ba6c22aa
branches: trunk
changeset: 338778:4266ba6c22aa
user: rmind <rmind%NetBSD.org@localhost>
date: Mon Jun 08 01:00:43 2015 +0000
description:
- npfctl: fix the confusion in the parser (0/0 case with no other filter).
- Always populate the error dictionary, not only for DEBUG/DIAGNOSTIC.
diffstat:
sys/net/npf/npf_ctl.c | 8 ++------
usr.sbin/npf/npfctl/npf_bpf_comp.c | 8 ++++++--
usr.sbin/npf/npfctl/npf_build.c | 8 ++++++--
3 files changed, 14 insertions(+), 10 deletions(-)
diffs (90 lines):
diff -r 9fb528c3badf -r 4266ba6c22aa sys/net/npf/npf_ctl.c
--- a/sys/net/npf/npf_ctl.c Sun Jun 07 21:05:33 2015 +0000
+++ b/sys/net/npf/npf_ctl.c Mon Jun 08 01:00:43 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_ctl.c,v 1.41 2015/03/20 23:36:28 rmind Exp $ */
+/* $NetBSD: npf_ctl.c,v 1.42 2015/06/08 01:00:43 rmind Exp $ */
/*-
* Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_ctl.c,v 1.41 2015/03/20 23:36:28 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_ctl.c,v 1.42 2015/06/08 01:00:43 rmind Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -49,13 +49,9 @@
#include "npf_impl.h"
#include "npf_conn.h"
-#if defined(DEBUG) || defined(DIAGNOSTIC)
#define NPF_ERR_DEBUG(e) \
prop_dictionary_set_cstring_nocopy((e), "source-file", __FILE__); \
prop_dictionary_set_uint32((e), "source-line", __LINE__);
-#else
-#define NPF_ERR_DEBUG(e)
-#endif
/*
* npfctl_switch: enable or disable packet inspection.
diff -r 9fb528c3badf -r 4266ba6c22aa usr.sbin/npf/npfctl/npf_bpf_comp.c
--- a/usr.sbin/npf/npfctl/npf_bpf_comp.c Sun Jun 07 21:05:33 2015 +0000
+++ b/usr.sbin/npf/npfctl/npf_bpf_comp.c Mon Jun 08 01:00:43 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_bpf_comp.c,v 1.7 2014/06/29 00:05:24 rmind Exp $ */
+/* $NetBSD: npf_bpf_comp.c,v 1.8 2015/06/08 01:00:43 rmind Exp $ */
/*-
* Copyright (c) 2010-2014 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npf_bpf_comp.c,v 1.7 2014/06/29 00:05:24 rmind Exp $");
+__RCSID("$NetBSD: npf_bpf_comp.c,v 1.8 2015/06/08 01:00:43 rmind Exp $");
#include <stdlib.h>
#include <stdbool.h>
@@ -189,6 +189,10 @@
struct bpf_program *bp = &ctx->prog;
const u_int retoff = bp->bf_len;
+ /* No instructions (optimised out). */
+ if (!bp->bf_len)
+ return NULL;
+
/* Add the return fragment (success and failure paths). */
struct bpf_insn insns_ret[] = {
BPF_STMT(BPF_RET+BPF_K, NPF_BPF_SUCCESS),
diff -r 9fb528c3badf -r 4266ba6c22aa usr.sbin/npf/npfctl/npf_build.c
--- a/usr.sbin/npf/npfctl/npf_build.c Sun Jun 07 21:05:33 2015 +0000
+++ b/usr.sbin/npf/npfctl/npf_build.c Mon Jun 08 01:00:43 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_build.c,v 1.39 2015/03/21 00:49:07 rmind Exp $ */
+/* $NetBSD: npf_build.c,v 1.40 2015/06/08 01:00:43 rmind Exp $ */
/*-
* Copyright (c) 2011-2014 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npf_build.c,v 1.39 2015/03/21 00:49:07 rmind Exp $");
+__RCSID("$NetBSD: npf_build.c,v 1.40 2015/06/08 01:00:43 rmind Exp $");
#include <sys/types.h>
#include <sys/mman.h>
@@ -368,6 +368,10 @@
/* Complete BPF byte-code and pass to the rule. */
struct bpf_program *bf = npfctl_bpf_complete(bc);
+ if (bf == NULL) {
+ npfctl_bpf_destroy(bc);
+ return true;
+ }
len = bf->bf_len * sizeof(struct bpf_insn);
if (npf_rule_setcode(rl, NPF_CODE_BPF, bf->bf_insns, len) == -1) {
Home |
Main Index |
Thread Index |
Old Index