mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-19 02:29:40 +00:00
Simplify jump instruction range checks.
MFC after: 1 month
This commit is contained in:
parent
3eb8b8bbeb
commit
28ae62aa8a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=182425
@ -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 New Issue
Block a user