Deleted Added
full compact
bpf_test.c (182417) bpf_test.c (182428)
1/*-
2 * Copyright (C) 2008 Jung-uk Kim <jkim@FreeBSD.org>. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 2008 Jung-uk Kim <jkim@FreeBSD.org>. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: head/tools/regression/bpf/bpf_filter/bpf_test.c 182417 2008-08-28 22:41:31Z jkim $");
27__FBSDID("$FreeBSD: head/tools/regression/bpf/bpf_filter/bpf_test.c 182428 2008-08-29 02:12:45Z jkim $");
28
29#include <signal.h>
30#include <stdio.h>
31#include <stdlib.h>
32
33#include <sys/types.h>
34
35#include <net/bpf.h>

--- 104 unchanged lines hidden (view full) ---

140 if ((p->code & 0xff00) ||
141 !(bpf_code_map[p->code >> 4] & (1 << (p->code & 0xf))))
142 return (0);
143 /*
144 * Check that that jumps are forward, and within
145 * the code block.
146 */
147 if (BPF_CLASS(p->code) == BPF_JMP) {
28
29#include <signal.h>
30#include <stdio.h>
31#include <stdlib.h>
32
33#include <sys/types.h>
34
35#include <net/bpf.h>

--- 104 unchanged lines hidden (view full) ---

140 if ((p->code & 0xff00) ||
141 !(bpf_code_map[p->code >> 4] & (1 << (p->code & 0xf))))
142 return (0);
143 /*
144 * Check that that jumps are forward, and within
145 * the code block.
146 */
147 if (BPF_CLASS(p->code) == BPF_JMP) {
148 register int from = i + 1;
148 register u_int offset;
149
149
150 if (BPF_OP(p->code) == BPF_JA) {
151 if (from >= len || p->k >= (u_int)len - from)
152 return (0);
153 }
154 else if (from >= len || p->jt >= len - from ||
155 p->jf >= len - from)
150 if (BPF_OP(p->code) == BPF_JA)
151 offset = p->k;
152 else
153 offset = p->jt > p->jf ? p->jt : p->jf;
154 if (offset >= (u_int)(len - i) - 1)
156 return (0);
157 }
158 /*
159 * Check that memory operations use valid addresses.
160 */
161 if ((BPF_CLASS(p->code) == BPF_ST ||
162 BPF_CLASS(p->code) == BPF_STX ||
163 ((BPF_CLASS(p->code) == BPF_LD ||

--- 101 unchanged lines hidden ---
155 return (0);
156 }
157 /*
158 * Check that memory operations use valid addresses.
159 */
160 if ((BPF_CLASS(p->code) == BPF_ST ||
161 BPF_CLASS(p->code) == BPF_STX ||
162 ((BPF_CLASS(p->code) == BPF_LD ||

--- 101 unchanged lines hidden ---