mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 12:08:20 +00:00
Actually check if the number of fields in a write are equal to the
number of fields required. Addresses BIT-1683 I do not think this quite fixes the underlying issue of BIT-1683 - it should not be possible to get to this state in normal operations. Also fixes a small memory leak for disabled writers.
This commit is contained in:
parent
0bc4a5ea52
commit
038dfa6273
6 changed files with 144 additions and 4 deletions
|
@ -175,10 +175,20 @@ void WriterFrontend::Init(int arg_num_fields, const Field* const * arg_fields)
|
|||
|
||||
}
|
||||
|
||||
void WriterFrontend::Write(int num_fields, Value** vals)
|
||||
void WriterFrontend::Write(int arg_num_fields, Value** vals)
|
||||
{
|
||||
if ( disabled )
|
||||
{
|
||||
DeleteVals(vals, arg_num_fields);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( arg_num_fields != num_fields )
|
||||
{
|
||||
reporter->InternalWarning("WriterFrontend %s expected %d fields in write, got %d. Skipping line.", name, num_fields, arg_num_fields);
|
||||
DeleteVals(vals, arg_num_fields);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( remote )
|
||||
remote_serializer->SendLogWrite(stream,
|
||||
|
@ -189,7 +199,7 @@ void WriterFrontend::Write(int num_fields, Value** vals)
|
|||
|
||||
if ( ! backend )
|
||||
{
|
||||
DeleteVals(vals);
|
||||
DeleteVals(vals, arg_num_fields);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -262,7 +272,7 @@ void WriterFrontend::Rotate(const char* rotated_path, double open, double close,
|
|||
log_mgr->FinishedRotation(this, 0, 0, 0, 0, false, terminating);
|
||||
}
|
||||
|
||||
void WriterFrontend::DeleteVals(Value** vals)
|
||||
void WriterFrontend::DeleteVals(Value** vals, int num_fields)
|
||||
{
|
||||
// Note this code is duplicated in Manager::DeleteVals().
|
||||
for ( int i = 0; i < num_fields; i++ )
|
||||
|
|
|
@ -203,7 +203,7 @@ public:
|
|||
protected:
|
||||
friend class Manager;
|
||||
|
||||
void DeleteVals(threading::Value** vals);
|
||||
void DeleteVals(threading::Value** vals, int num_fields);
|
||||
|
||||
EnumVal* stream;
|
||||
EnumVal* writer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue