mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix misc. issues reported by Coverity.
Some uninitialized values, a possible null pointer dereference, and time-of-check-time-of-use on reading random seed file.
This commit is contained in:
parent
50784c64bc
commit
38ae7c98b4
10 changed files with 22 additions and 12 deletions
|
@ -14,8 +14,11 @@
|
|||
|
||||
FlowSrc::FlowSrc()
|
||||
{ // TODO: v9.
|
||||
selectable_fd = -1;
|
||||
idle = false;
|
||||
data = 0;
|
||||
pdu_len = -1;
|
||||
exporter_ip = 0;
|
||||
current_timestamp = next_timestamp = 0.0;
|
||||
netflow_analyzer = new binpac::NetFlow::NetFlow_Analyzer();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@ PacketSortElement::PacketSortElement(PktSrc* arg_src,
|
|||
|
||||
is_tcp = 0;
|
||||
ip_hdr = 0;
|
||||
tcp_flags = 0;
|
||||
endp = 0;
|
||||
payload_length = 0;
|
||||
key = 0;
|
||||
|
||||
// Now check if it is a "parsable" TCP packet.
|
||||
|
|
|
@ -113,7 +113,8 @@ protected:
|
|||
conns = 0;
|
||||
conn_cookie = 0;
|
||||
peer = SOURCE_LOCAL;
|
||||
};
|
||||
filename = 0;
|
||||
}
|
||||
|
||||
Type type;
|
||||
SerialInfo info;
|
||||
|
|
|
@ -648,6 +648,7 @@ PktDumper::PktDumper(const char* arg_filename, bool arg_append)
|
|||
is_error = false;
|
||||
append = arg_append;
|
||||
dumper = 0;
|
||||
open_time = 0.0;
|
||||
|
||||
// We need a pcap_t with a reasonable link-layer type. We try to get it
|
||||
// from the packet sources. If not available, we fall back to Ethernet.
|
||||
|
|
|
@ -86,6 +86,7 @@ bool LoadPolicyFileText(const char* policy_filename)
|
|||
char buf[256];
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
reporter->Error("fstat failed on %s: %s", policy_filename, buf);
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -3321,6 +3321,9 @@ SocketComm::SocketComm()
|
|||
id_counter = 10000;
|
||||
parent_peer = 0;
|
||||
parent_msgstate = TYPE;
|
||||
parent_id = RemoteSerializer::PEER_NONE;
|
||||
parent_msgtype = 0;
|
||||
parent_args = 0;
|
||||
shutting_conns_down = false;
|
||||
terminating = false;
|
||||
killing = false;
|
||||
|
|
|
@ -31,8 +31,11 @@ flow NetFlow_Flow {
|
|||
internal_type("nf_v5_record")->AsRecordType();
|
||||
nfheader_id_type =
|
||||
internal_type("nfheader_id")->AsRecordType();
|
||||
pdu_id = 0;
|
||||
identifier = NULL;
|
||||
exporter_ip = 0;
|
||||
uptime = 0;
|
||||
export_time = 0;
|
||||
pdu_id = 0;
|
||||
%}
|
||||
|
||||
# %cleanup does not only put the cleanup code into the destructor,
|
||||
|
|
|
@ -1518,7 +1518,6 @@ int Manager::PutTable(Stream* i, const Value* const *vals)
|
|||
EnumVal* ev;
|
||||
int startpos = 0;
|
||||
Val* predidx = ValueToRecordVal(vals, stream->itype, &startpos);
|
||||
Ref(valval);
|
||||
|
||||
if ( updated )
|
||||
ev = new EnumVal(BifEnum::Input::EVENT_CHANGED,
|
||||
|
@ -1529,7 +1528,10 @@ int Manager::PutTable(Stream* i, const Value* const *vals)
|
|||
|
||||
bool result;
|
||||
if ( stream->num_val_fields > 0 ) // we have values
|
||||
{
|
||||
Ref(valval);
|
||||
result = CallPred(stream->pred, 3, ev, predidx, valval);
|
||||
}
|
||||
else // no values
|
||||
result = CallPred(stream->pred, 2, ev, predidx);
|
||||
|
||||
|
|
|
@ -289,7 +289,8 @@ bool Raw::OpenInput()
|
|||
return false;
|
||||
}
|
||||
|
||||
fcntl(fileno(file), F_SETFD, FD_CLOEXEC);
|
||||
if ( ! SetFDFlags(fileno(file), F_SETFD, FD_CLOEXEC) )
|
||||
Warning(Fmt("Init: cannot set close-on-exec for %s", fname.c_str()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -652,16 +652,8 @@ void hmac_md5(size_t size, const unsigned char* bytes, unsigned char digest[16])
|
|||
static bool read_random_seeds(const char* read_file, uint32* seed,
|
||||
uint32* buf, int bufsiz)
|
||||
{
|
||||
struct stat st;
|
||||
FILE* f = 0;
|
||||
|
||||
if ( stat(read_file, &st) < 0 )
|
||||
{
|
||||
reporter->Warning("Seed file '%s' does not exist: %s",
|
||||
read_file, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! (f = fopen(read_file, "r")) )
|
||||
{
|
||||
reporter->Warning("Could not open seed file '%s': %s",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue