mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath: Fix global opaque val segfault, addresses BIT-1071 Fix malloc/delete mismatch. Fix invalid pointer dereference in AsciiFormatter.
This commit is contained in:
commit
23144e44a7
10 changed files with 47 additions and 28 deletions
8
CHANGES
8
CHANGES
|
@ -1,4 +1,12 @@
|
|||
|
||||
2.1-1154 | 2013-08-30 08:27:45 -0700
|
||||
|
||||
* Fix global opaque val segfault. Addresses BIT-1071. (Jon Siwek)
|
||||
|
||||
* Fix malloc/delete mismatch. (Jon Siwek)
|
||||
|
||||
* Fix invalid pointer dereference in AsciiFormatter. (Jon Siwek)
|
||||
|
||||
2.1-1150 | 2013-08-29 13:43:01 -0700
|
||||
|
||||
* Fix input framework memory leaks. (Jon Siwek)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
2.1-1150
|
||||
2.1-1154
|
||||
|
|
|
@ -242,13 +242,6 @@ StringVal* global_hash_seed;
|
|||
|
||||
bro_uint_t bits_per_uid;
|
||||
|
||||
OpaqueType* md5_type;
|
||||
OpaqueType* sha1_type;
|
||||
OpaqueType* sha256_type;
|
||||
OpaqueType* entropy_type;
|
||||
OpaqueType* topk_type;
|
||||
OpaqueType* bloomfilter_type;
|
||||
|
||||
#include "const.bif.netvar_def"
|
||||
#include "types.bif.netvar_def"
|
||||
#include "event.bif.netvar_def"
|
||||
|
@ -312,13 +305,6 @@ void init_general_global_var()
|
|||
global_hash_seed = opt_internal_string("global_hash_seed");
|
||||
|
||||
bits_per_uid = opt_internal_unsigned("bits_per_uid");
|
||||
|
||||
md5_type = new OpaqueType("md5");
|
||||
sha1_type = new OpaqueType("sha1");
|
||||
sha256_type = new OpaqueType("sha256");
|
||||
entropy_type = new OpaqueType("entropy");
|
||||
topk_type = new OpaqueType("topk");
|
||||
bloomfilter_type = new OpaqueType("bloomfilter");
|
||||
}
|
||||
|
||||
void init_net_var()
|
||||
|
|
|
@ -246,14 +246,6 @@ extern StringVal* global_hash_seed;
|
|||
|
||||
extern bro_uint_t bits_per_uid;
|
||||
|
||||
class OpaqueType;
|
||||
extern OpaqueType* md5_type;
|
||||
extern OpaqueType* sha1_type;
|
||||
extern OpaqueType* sha256_type;
|
||||
extern OpaqueType* entropy_type;
|
||||
extern OpaqueType* topk_type;
|
||||
extern OpaqueType* bloomfilter_type;
|
||||
|
||||
// Initializes globals that don't pertain to network/event analysis.
|
||||
extern void init_general_global_var();
|
||||
|
||||
|
|
|
@ -609,6 +609,13 @@ protected:
|
|||
BroType* yield_type;
|
||||
};
|
||||
|
||||
extern OpaqueType* md5_type;
|
||||
extern OpaqueType* sha1_type;
|
||||
extern OpaqueType* sha256_type;
|
||||
extern OpaqueType* entropy_type;
|
||||
extern OpaqueType* topk_type;
|
||||
extern OpaqueType* bloomfilter_type;
|
||||
|
||||
// Returns the BRO basic (non-parameterized) type with the given type.
|
||||
extern BroType* base_type(TypeTag tag);
|
||||
|
||||
|
|
|
@ -2090,9 +2090,7 @@ HashKey* Manager::HashValues(const int num_elements, const Value* const *vals)
|
|||
return NULL;
|
||||
|
||||
int position = 0;
|
||||
char *data = (char*) malloc(length);
|
||||
if ( data == 0 )
|
||||
reporter->InternalError("Could not malloc?");
|
||||
char *data = new char[length];
|
||||
|
||||
for ( int i = 0; i < num_elements; i++ )
|
||||
{
|
||||
|
@ -2108,7 +2106,7 @@ HashKey* Manager::HashValues(const int num_elements, const Value* const *vals)
|
|||
}
|
||||
|
||||
HashKey *key = new HashKey(data, length);
|
||||
delete data;
|
||||
delete [] data;
|
||||
|
||||
assert(position == length);
|
||||
return key;
|
||||
|
|
14
src/main.cc
14
src/main.cc
|
@ -124,6 +124,13 @@ vector<string> params;
|
|||
char* proc_status_file = 0;
|
||||
int snaplen = 0; // this gets set from the scripting-layer's value
|
||||
|
||||
OpaqueType* md5_type = 0;
|
||||
OpaqueType* sha1_type = 0;
|
||||
OpaqueType* sha256_type = 0;
|
||||
OpaqueType* entropy_type = 0;
|
||||
OpaqueType* topk_type = 0;
|
||||
OpaqueType* bloomfilter_type = 0;
|
||||
|
||||
extern std::list<BroDoc*> docs_generated;
|
||||
|
||||
// Keep copy of command line
|
||||
|
@ -845,6 +852,13 @@ int main(int argc, char** argv)
|
|||
|
||||
input::reader::Raw::ClassInit();
|
||||
|
||||
md5_type = new OpaqueType("md5");
|
||||
sha1_type = new OpaqueType("sha1");
|
||||
sha256_type = new OpaqueType("sha256");
|
||||
entropy_type = new OpaqueType("entropy");
|
||||
topk_type = new OpaqueType("topk");
|
||||
bloomfilter_type = new OpaqueType("bloomfilter");
|
||||
|
||||
// The leak-checker tends to produce some false
|
||||
// positives (memory which had already been
|
||||
// allocated before we start the checking is
|
||||
|
|
|
@ -247,7 +247,8 @@ threading::Value* AsciiFormatter::ParseValue(string s, string name, TypeTag type
|
|||
goto parse_error;
|
||||
}
|
||||
|
||||
uint8_t width = (uint8_t) strtol(s.substr(pos+1).c_str(), &end, 10);
|
||||
string width_str = s.substr(pos + 1);
|
||||
uint8_t width = (uint8_t) strtol(width_str.c_str(), &end, 10);
|
||||
|
||||
if ( CheckNumberError(s, end) )
|
||||
goto parse_error;
|
||||
|
|
1
testing/btest/Baseline/core.global_opaque_val/output
Normal file
1
testing/btest/Baseline/core.global_opaque_val/output
Normal file
|
@ -0,0 +1 @@
|
|||
7b0391feb2e0cd271f1cf39aafb4376f
|
12
testing/btest/core/global_opaque_val.bro
Normal file
12
testing/btest/core/global_opaque_val.bro
Normal file
|
@ -0,0 +1,12 @@
|
|||
# @TEST-EXEC: bro -b %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
global test = md5_hash_init();
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
md5_hash_update(test, "one");
|
||||
md5_hash_update(test, "two");
|
||||
md5_hash_update(test, "three");
|
||||
print md5_hash_finish(test);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue