mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/coverity'
* origin/topic/jsiwek/coverity: Fix uninitialized (or unused) fields. Remove logically dead code. Remove dead/unfinished code in unary not expr. Fix logic for failed DNS TXT lookups. A couple null ptr checks. Improve return value checking and error handling. Remove unused variable assignments, dead code. Prevent division/modulo by zero in scripts. Fix unintentional always-false condition. Fix invalidated iterator usage. Fix DNS_Mgr iterator mismatch. Set safe umask when creating script profiler tmp files. Fix nesting/indent level whitespace mismatch. Add checks to avoid improper negative values use. BIT-1085 #merged
This commit is contained in:
commit
d127d8d01d
86 changed files with 517 additions and 242 deletions
|
@ -295,7 +295,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
|||
return false;
|
||||
}
|
||||
|
||||
RecordType* columns = sval->Lookup(rtype->FieldOffset("columns"))
|
||||
RecordType* columns = sval->Lookup("columns")
|
||||
->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||
|
||||
bool log_attr_present = false;
|
||||
|
@ -322,7 +322,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
|||
return false;
|
||||
}
|
||||
|
||||
Val* event_val = sval->Lookup(rtype->FieldOffset("ev"));
|
||||
Val* event_val = sval->Lookup("ev");
|
||||
Func* event = event_val ? event_val->AsFunc() : 0;
|
||||
|
||||
if ( event )
|
||||
|
@ -579,19 +579,18 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
|||
return false;
|
||||
|
||||
// Find the right writer type.
|
||||
int idx = rtype->FieldOffset("writer");
|
||||
EnumVal* writer = fval->LookupWithDefault(idx)->AsEnumVal();
|
||||
EnumVal* writer = fval->Lookup("writer", true)->AsEnumVal();
|
||||
|
||||
// Create a new Filter instance.
|
||||
|
||||
Val* name = fval->LookupWithDefault(rtype->FieldOffset("name"));
|
||||
Val* pred = fval->LookupWithDefault(rtype->FieldOffset("pred"));
|
||||
Val* path_func = fval->LookupWithDefault(rtype->FieldOffset("path_func"));
|
||||
Val* log_local = fval->LookupWithDefault(rtype->FieldOffset("log_local"));
|
||||
Val* log_remote = fval->LookupWithDefault(rtype->FieldOffset("log_remote"));
|
||||
Val* interv = fval->LookupWithDefault(rtype->FieldOffset("interv"));
|
||||
Val* postprocessor = fval->LookupWithDefault(rtype->FieldOffset("postprocessor"));
|
||||
Val* config = fval->LookupWithDefault(rtype->FieldOffset("config"));
|
||||
Val* name = fval->Lookup("name", true);
|
||||
Val* pred = fval->Lookup("pred", true);
|
||||
Val* path_func = fval->Lookup("path_func", true);
|
||||
Val* log_local = fval->Lookup("log_local", true);
|
||||
Val* log_remote = fval->Lookup("log_remote", true);
|
||||
Val* interv = fval->Lookup("interv", true);
|
||||
Val* postprocessor = fval->Lookup("postprocessor", true);
|
||||
Val* config = fval->Lookup("config", true);
|
||||
|
||||
Filter* filter = new Filter;
|
||||
filter->name = name->AsString()->CheckString();
|
||||
|
@ -616,8 +615,8 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
|||
|
||||
// Build the list of fields that the filter wants included, including
|
||||
// potentially rolling out fields.
|
||||
Val* include = fval->Lookup(rtype->FieldOffset("include"));
|
||||
Val* exclude = fval->Lookup(rtype->FieldOffset("exclude"));
|
||||
Val* include = fval->Lookup("include");
|
||||
Val* exclude = fval->Lookup("exclude");
|
||||
|
||||
filter->num_fields = 0;
|
||||
filter->fields = 0;
|
||||
|
@ -631,7 +630,7 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
|||
}
|
||||
|
||||
// Get the path for the filter.
|
||||
Val* path_val = fval->Lookup(rtype->FieldOffset("path"));
|
||||
Val* path_val = fval->Lookup("path");
|
||||
|
||||
if ( path_val )
|
||||
{
|
||||
|
|
|
@ -242,17 +242,6 @@ public:
|
|||
* Note: Exactly one of the two FinishedRotation() methods must be
|
||||
* called by a writer's implementation of DoRotate() once rotation
|
||||
* has finished.
|
||||
*
|
||||
* @param new_name The filename of the rotated file.
|
||||
*
|
||||
* @param old_name The filename of the original file.
|
||||
*
|
||||
* @param open: The timestamp when the original file was opened.
|
||||
*
|
||||
* @param close: The timestamp when the origina file was closed.
|
||||
*
|
||||
* @param terminating: True if the original rotation request occured
|
||||
* due to the main Bro process shutting down.
|
||||
*/
|
||||
bool FinishedRotation();
|
||||
|
||||
|
|
|
@ -112,6 +112,9 @@ WriterFrontend::WriterFrontend(const WriterBackend::WriterInfo& arg_info, EnumVa
|
|||
write_buffer_pos = 0;
|
||||
info = new WriterBackend::WriterInfo(arg_info);
|
||||
|
||||
num_fields = 0;
|
||||
fields = 0;
|
||||
|
||||
const char* w = arg_writer->Type()->AsEnumType()->Lookup(arg_writer->InternalInt());
|
||||
name = copy_string(fmt("%s/%s", arg_info.path, w));
|
||||
|
||||
|
|
|
@ -261,7 +261,16 @@ bool Ascii::DoRotate(const char* rotated_path, double open, double close, bool t
|
|||
CloseFile(close);
|
||||
|
||||
string nname = string(rotated_path) + "." + LogExt();
|
||||
rename(fname.c_str(), nname.c_str());
|
||||
|
||||
if ( rename(fname.c_str(), nname.c_str()) != 0 )
|
||||
{
|
||||
char buf[256];
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
Error(Fmt("failed to rename %s to %s: %s", fname.c_str(),
|
||||
nname.c_str(), buf));
|
||||
FinishedRotation();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! FinishedRotation(nname.c_str(), fname.c_str(), open, close, terminating) )
|
||||
{
|
||||
|
|
|
@ -233,6 +233,10 @@ DataSeries::DataSeries(WriterFrontend* frontend) : WriterBackend(frontend)
|
|||
ds_set_separator = ",";
|
||||
|
||||
ascii = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo());
|
||||
|
||||
compress_type = Extent::compress_none;
|
||||
log_file = 0;
|
||||
log_output = 0;
|
||||
}
|
||||
|
||||
DataSeries::~DataSeries()
|
||||
|
@ -423,7 +427,16 @@ bool DataSeries::DoRotate(const char* rotated_path, double open, double close, b
|
|||
|
||||
string dsname = string(Info().path) + ".ds";
|
||||
string nname = string(rotated_path) + ".ds";
|
||||
rename(dsname.c_str(), nname.c_str());
|
||||
|
||||
if ( rename(dsname.c_str(), nname.c_str()) != 0 )
|
||||
{
|
||||
char buf[256];
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
Error(Fmt("failed to rename %s to %s: %s", dsname.c_str(),
|
||||
nname.c_str(), buf));
|
||||
FinishedRotation();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! FinishedRotation(nname.c_str(), dsname.c_str(), open, close, terminating) )
|
||||
{
|
||||
|
|
|
@ -16,7 +16,9 @@ using namespace writer;
|
|||
using threading::Value;
|
||||
using threading::Field;
|
||||
|
||||
SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend)
|
||||
SQLite::SQLite(WriterFrontend* frontend)
|
||||
: WriterBackend(frontend),
|
||||
fields(), num_fields(), db(), st()
|
||||
{
|
||||
set_separator.assign(
|
||||
(const char*) BifConst::LogSQLite::set_separator->Bytes(),
|
||||
|
@ -33,9 +35,7 @@ SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend)
|
|||
BifConst::LogSQLite::empty_field->Len()
|
||||
);
|
||||
|
||||
db = 0;
|
||||
io = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo(set_separator, unset_field, empty_field));
|
||||
st = 0;
|
||||
}
|
||||
|
||||
SQLite::~SQLite()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue