Merge remote-tracking branch 'origin/topic/johanna/bit-1683'

Looks like the right fix. Two tiny tweaks:

     - changed the order of arguments for DeleteVals() for consistency
       with the corresponding Manager function.

     - turned the InternalWarning into a Warning: if I understand
       correctly, this can happen when scripts on nodes diverge; which
       is a user-side problem, not an internal Bro logic issue.

BIT-1683 #merged

* origin/topic/johanna/bit-1683:
  Actually check if the number of fields in a write are equal to the number of fields required.
This commit is contained in:
Robin Sommer 2016-09-27 11:44:33 -07:00
commit 4059d4b4f1
8 changed files with 159 additions and 5 deletions

View file

@ -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(arg_num_fields, vals);
return;
}
if ( arg_num_fields != num_fields )
{
reporter->Warning("WriterFrontend %s expected %d fields in write, got %d. Skipping line.", name, num_fields, arg_num_fields);
DeleteVals(arg_num_fields, vals);
return;
}
if ( remote )
remote_serializer->SendLogWrite(stream,
@ -189,7 +199,7 @@ void WriterFrontend::Write(int num_fields, Value** vals)
if ( ! backend )
{
DeleteVals(vals);
DeleteVals(arg_num_fields, vals);
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(int num_fields, Value** vals)
{
// Note this code is duplicated in Manager::DeleteVals().
for ( int i = 0; i < num_fields; i++ )

View file

@ -203,7 +203,7 @@ public:
protected:
friend class Manager;
void DeleteVals(threading::Value** vals);
void DeleteVals(int num_fields, threading::Value** vals);
EnumVal* stream;
EnumVal* writer;