mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
Simplify jump instruction range checks.
MFC after: 1 month
This commit is contained in:
parent
3eb8b8bbeb
commit
28ae62aa8a
1 changed files with 6 additions and 7 deletions
|
|
@ -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;
|
||||
}
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue