diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 63f1e15e58..5ca12c32e1 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -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() ); } diff --git a/src/input/readers/SQLite.cc b/src/input/readers/SQLite.cc index 0a9d8381a4..1f779c5444 100644 --- a/src/input/readers/SQLite.cc +++ b/src/input/readers/SQLite.cc @@ -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); diff --git a/testing/btest/scripts/base/frameworks/input/sqlite/basic.bro b/testing/btest/scripts/base/frameworks/input/sqlite/basic.bro index 3f30f84de5..a484a035de 100644 --- a/testing/btest/scripts/base/frameworks/input/sqlite/basic.bro +++ b/testing/btest/scripts/base/frameworks/input/sqlite/basic.bro @@ -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; diff --git a/testing/btest/scripts/base/frameworks/input/sqlite/port.bro b/testing/btest/scripts/base/frameworks/input/sqlite/port.bro index 4501f28b2b..39401a8290 100644 --- a/testing/btest/scripts/base/frameworks/input/sqlite/port.bro +++ b/testing/btest/scripts/base/frameworks/input/sqlite/port.bro @@ -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;