mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
fix bug in input-manager regarding enums that a writer reads without
0-terminating the string
This commit is contained in:
parent
6c99df508c
commit
8f7619971f
4 changed files with 15 additions and 8 deletions
|
@ -2119,12 +2119,16 @@ Val* Manager::ValueToVal(const Value* val, BroType* request_type)
|
|||
case TYPE_ENUM: {
|
||||
// well, this is kind of stupid, because EnumType just mangles the module name and the var name together again...
|
||||
// but well
|
||||
string module = extract_module_name(val->val.string_val.data);
|
||||
string var = extract_var_name(val->val.string_val.data);
|
||||
// convert to string first to not have to deal with missing \0's...
|
||||
string module_string(val->val.string_val.data, val->val.string_val.length);
|
||||
string var_string(val->val.string_val.data, val->val.string_val.length);
|
||||
|
||||
string module = extract_module_name(module_string.c_str());
|
||||
string var = extract_var_name(var_string.c_str());
|
||||
bro_int_t index = request_type->AsEnumType()->Lookup(module, var.c_str());
|
||||
if ( index == -1 )
|
||||
reporter->InternalError("Value not found in enum mappimg. Module: %s, var: %s",
|
||||
module.c_str(), var.c_str());
|
||||
reporter->InternalError("Value not found in enum mappimg. Module: %s, var: %s, var size: %d",
|
||||
module.c_str(), var.c_str(), var.size());
|
||||
|
||||
return new EnumVal(index, request_type->Ref()->AsEnumType() );
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
|||
|
||||
char *out = new char[length];
|
||||
memcpy(out, text, length);
|
||||
|
||||
|
||||
val->val.string_val.length = length;
|
||||
val->val.string_val.data = out;
|
||||
break;
|
||||
|
@ -250,7 +250,7 @@ bool SQLite::DoUpdate()
|
|||
|
||||
|
||||
|
||||
for ( unsigned int i = 0; i < numcolumns; ++i )
|
||||
for ( int i = 0; i < numcolumns; ++i )
|
||||
{
|
||||
const char *name = sqlite3_column_name(st, i);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# @TEST-EXEC: cat conn.sql | sqlite3 conn.sqlite
|
||||
# @TEST-EXEC: btest-bg-run bro bro -b --pseudo-realtime -r $TRACES/socks.trace %INPUT
|
||||
# @TEST-EXEC: btest-bg-run bro bro -b %INPUT
|
||||
# @TEST-EXEC: btest-bg-wait -k 5
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
|
@ -67,6 +67,7 @@ COMMIT;
|
|||
|
||||
@load base/protocols/conn
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
redef Input::accept_unsupported_types = T;
|
||||
|
||||
global outfile: file;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# @TEST-EXEC: cat port.sql | sqlite3 port.sqlite
|
||||
# @TEST-EXEC: btest-bg-run bro bro -b --pseudo-realtime -r $TRACES/socks.trace %INPUT
|
||||
# @TEST-EXEC: btest-bg-run bro bro -b %INPUT
|
||||
# @TEST-EXEC: btest-bg-wait -k 5
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
|
@ -15,6 +15,8 @@ INSERT INTO "port" VALUES(6162,'tcp');
|
|||
COMMIT;
|
||||
@TEST-END-FILE
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global outfile: file;
|
||||
|
||||
module A;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue