- 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:
Jung-uk Kim 2006-01-03 20:26:03 +00:00
parent 8294689115
commit dccb7faff6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=153995
3 changed files with 9 additions and 1 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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) {
/*