Simplify jump instruction range checks.

MFC after:	1 month
This commit is contained in:
Jung-uk Kim 2008-08-29 01:47:45 +00:00
parent 3eb8b8bbeb
commit 28ae62aa8a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=182425

View File

@ -552,14 +552,13 @@ bpf_validate(f, len)
* the code block.
*/
if (BPF_CLASS(p->code) == BPF_JMP) {
register int from = i + 1;
register u_int offset;
if (BPF_OP(p->code) == BPF_JA) {
if (from >= len || p->k >= len - from)
return 0;
}
else if (from >= len || p->jt >= len - from ||
p->jf >= len - from)
if (BPF_OP(p->code) == BPF_JA)
offset = p->k;
else
offset = p->jt > p->jf ? p->jt : p->jf;
if (offset >= (u_int)(len - i) - 1)
return 0;
}
/*