mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix/improve dereference-before-null-checks.
This commit is contained in:
parent
3d81432a1e
commit
735d2c402a
8 changed files with 19 additions and 30 deletions
|
@ -1074,9 +1074,8 @@ bool ChunkedIOSSL::Read(Chunk** chunk, bool mayblock)
|
|||
read_state = LEN;
|
||||
|
||||
#ifdef DEBUG
|
||||
if ( *chunk )
|
||||
DBG_LOG(DBG_CHUNKEDIO, "ssl read of size %d [%s]",
|
||||
(*chunk)->len, fmt_bytes((*chunk)->data, 20));
|
||||
DBG_LOG(DBG_CHUNKEDIO, "ssl read of size %d [%s]",
|
||||
(*chunk)->len, fmt_bytes((*chunk)->data, 20));
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
|
11
src/Desc.cc
11
src/Desc.cc
|
@ -23,11 +23,7 @@ ODesc::ODesc(desc_type t, BroFile* arg_f)
|
|||
size = DEFAULT_SIZE;
|
||||
base = safe_malloc(size);
|
||||
((char*) base)[0] = '\0';
|
||||
|
||||
offset = 0;
|
||||
|
||||
if ( ! base )
|
||||
OutOfMemory();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -337,16 +333,9 @@ void ODesc::Grow(unsigned int n)
|
|||
{
|
||||
size *= 2;
|
||||
base = safe_realloc(base, size);
|
||||
if ( ! base )
|
||||
OutOfMemory();
|
||||
}
|
||||
}
|
||||
|
||||
void ODesc::OutOfMemory()
|
||||
{
|
||||
reporter->InternalError("out of memory");
|
||||
}
|
||||
|
||||
void ODesc::Clear()
|
||||
{
|
||||
offset = 0;
|
||||
|
|
|
@ -149,8 +149,6 @@ protected:
|
|||
// Make buffer big enough for n bytes beyond bufp.
|
||||
void Grow(unsigned int n);
|
||||
|
||||
void OutOfMemory();
|
||||
|
||||
/**
|
||||
* Returns the location of the first place in the bytes to be hex-escaped.
|
||||
*
|
||||
|
|
|
@ -2925,8 +2925,7 @@ void RemoteSerializer::GotID(ID* id, Val* val)
|
|||
const char* desc = val->AsString()->CheckString();
|
||||
current_peer->val->Assign(4, new StringVal(desc));
|
||||
|
||||
Log(LogInfo, fmt("peer_description is %s",
|
||||
(desc && *desc) ? desc : "not set"),
|
||||
Log(LogInfo, fmt("peer_description is %s", *desc ? desc : "not set"),
|
||||
current_peer);
|
||||
|
||||
Unref(id);
|
||||
|
|
|
@ -378,7 +378,7 @@ bool Serializer::UnserializeCall(UnserialInfo* info)
|
|||
ignore = true;
|
||||
}
|
||||
|
||||
if ( info->print && types && ! ignore )
|
||||
if ( info->print && ! ignore )
|
||||
v->Describe(&d);
|
||||
}
|
||||
|
||||
|
|
|
@ -147,10 +147,12 @@ void PIA_UDP::ActivateAnalyzer(analyzer::Tag tag, const Rule* rule)
|
|||
return;
|
||||
|
||||
analyzer::Analyzer* a = Parent()->AddChildAnalyzer(tag);
|
||||
a->SetSignature(rule);
|
||||
|
||||
if ( a )
|
||||
ReplayPacketBuffer(a);
|
||||
if ( ! a )
|
||||
return;
|
||||
|
||||
a->SetSignature(rule);
|
||||
ReplayPacketBuffer(a);
|
||||
}
|
||||
|
||||
void PIA_UDP::DeactivateAnalyzer(analyzer::Tag tag)
|
||||
|
|
|
@ -291,6 +291,12 @@ bool Raw::CloseInput()
|
|||
|
||||
bool Raw::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fields)
|
||||
{
|
||||
if ( ! info.source || strlen(info.source) == 0 )
|
||||
{
|
||||
Error("No source path provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
fname = info.source;
|
||||
mtime = 0;
|
||||
execute = false;
|
||||
|
@ -298,7 +304,6 @@ bool Raw::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fie
|
|||
int want_fields = 1;
|
||||
bool result;
|
||||
|
||||
// do Initialization
|
||||
string source = string(info.source);
|
||||
char last = info.source[source.length() - 1];
|
||||
if ( last == '|' )
|
||||
|
@ -307,12 +312,6 @@ bool Raw::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fie
|
|||
fname = source.substr(0, fname.length() - 1);
|
||||
}
|
||||
|
||||
if ( ! info.source || strlen(info.source) == 0 )
|
||||
{
|
||||
Error("No source path provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
map<const char*, const char*>::const_iterator it = info.config.find("stdin"); // data that is sent to the child process
|
||||
if ( it != info.config.end() )
|
||||
{
|
||||
|
|
|
@ -187,11 +187,14 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
|||
if ( subpos != -1 )
|
||||
{
|
||||
const char *text = (const char*) sqlite3_column_text(st, subpos);
|
||||
string s(text, sqlite3_column_bytes(st, subpos));
|
||||
|
||||
if ( text == 0 )
|
||||
Error("Port protocol definition did not contain text");
|
||||
else
|
||||
{
|
||||
string s(text, sqlite3_column_bytes(st, subpos));
|
||||
val->val.port_val.proto = io->ParseProto(s);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue