mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
GH-208: change invalid subnet expressions to a runtime error
Rather than abort.
This commit is contained in:
parent
67484a90fa
commit
01a8418d79
4 changed files with 65 additions and 11 deletions
15
src/Expr.cc
15
src/Expr.cc
|
@ -1795,7 +1795,20 @@ Val* DivideExpr::AddrFold(Val* v1, Val* v2) const
|
|||
else
|
||||
mask = static_cast<uint32>(v2->InternalInt());
|
||||
|
||||
return new SubNetVal(v1->AsAddr(), mask);
|
||||
auto& a = v1->AsAddr();
|
||||
|
||||
if ( a.GetFamily() == IPv4 )
|
||||
{
|
||||
if ( mask > 32 )
|
||||
RuntimeError(fmt("bad IPv4 subnet prefix length: %" PRIu32, mask));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mask > 128 )
|
||||
RuntimeError(fmt("bad IPv6 subnet prefix length: %" PRIu32, mask));
|
||||
}
|
||||
|
||||
return new SubNetVal(a, mask);
|
||||
}
|
||||
|
||||
IMPLEMENT_SERIAL(DivideExpr, SER_DIVIDE_EXPR);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue