- Explicitly validate an empty filter to match bpf_filter() comment[1].
- Do not use BPF JIT compiler for an empty filter. [1] Pointed out by: darrenr
This commit is contained in:
parent
8294689115
commit
dccb7faff6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=153995
@ -103,6 +103,10 @@ bpf_jit_compile(struct bpf_insn *prog, u_int nins, int *mem)
|
||||
*/
|
||||
emit_func emitm;
|
||||
|
||||
/* Do not compile an empty filter. */
|
||||
if (nins == 0)
|
||||
return NULL;
|
||||
|
||||
/* Allocate the reference table for the jumps */
|
||||
stream.refs = (u_int *)malloc((nins + 1) * sizeof(u_int),
|
||||
M_BPFJIT, M_NOWAIT);
|
||||
|
@ -103,6 +103,10 @@ bpf_jit_compile(struct bpf_insn *prog, u_int nins, int *mem)
|
||||
*/
|
||||
emit_func emitm;
|
||||
|
||||
/* Do not compile an empty filter. */
|
||||
if (nins == 0)
|
||||
return NULL;
|
||||
|
||||
/* Allocate the reference table for the jumps */
|
||||
stream.refs = (u_int *)malloc((nins + 1) * sizeof(u_int),
|
||||
M_BPFJIT, M_NOWAIT);
|
||||
|
@ -521,7 +521,7 @@ bpf_validate(f, len)
|
||||
register const struct bpf_insn *p;
|
||||
|
||||
if (len < 1)
|
||||
return 0;
|
||||
return 1;
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user