mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Fix logging filter over-allocation and leak.
The leak could happen in a couple cases where adding a log filter fails: OOM and unsupported field type.
This commit is contained in:
parent
0678468353
commit
f9dc48e573
1 changed files with 5 additions and 1 deletions
|
@ -538,10 +538,11 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
|
||||||
|
|
||||||
filter->fields = (threading::Field**)
|
filter->fields = (threading::Field**)
|
||||||
realloc(filter->fields,
|
realloc(filter->fields,
|
||||||
sizeof(threading::Field) * ++filter->num_fields);
|
sizeof(threading::Field*) * ++filter->num_fields);
|
||||||
|
|
||||||
if ( ! filter->fields )
|
if ( ! filter->fields )
|
||||||
{
|
{
|
||||||
|
--filter->num_fields;
|
||||||
reporter->Error("out of memory in add_filter");
|
reporter->Error("out of memory in add_filter");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -623,7 +624,10 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
||||||
include ? include->AsTableVal() : 0,
|
include ? include->AsTableVal() : 0,
|
||||||
exclude ? exclude->AsTableVal() : 0,
|
exclude ? exclude->AsTableVal() : 0,
|
||||||
"", list<int>()) )
|
"", list<int>()) )
|
||||||
|
{
|
||||||
|
delete filter;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the path for the filter.
|
// Get the path for the filter.
|
||||||
Val* path_val = fval->Lookup(rtype->FieldOffset("path"));
|
Val* path_val = fval->Lookup(rtype->FieldOffset("path"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue