From cb6f6467c7f93da79c755479cc8eba40f6c75ae3 Mon Sep 17 00:00:00 2001 From: Jon Crussell Date: Sat, 9 Nov 2013 18:04:36 -0800 Subject: [PATCH] Fixed Segmentation fault in SQLite Writer. Segmentation fault caused by accessing fields with pos which is one-based for setting SQLite field values. Fix is to simply subtract one from pos. Discovered when trying to store HTTP traffic to a SQLite database with the following Bro script: event bro_init() { local filter: Log::Filter = [ $name = "sqlite", $path = "http", $config = table(["tablename"] = "http_logs"), $writer = Log::WRITER_SQLITE ]; Log::add_filter(HTTP::LOG, filter); } --- src/logging/writers/SQLite.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/logging/writers/SQLite.cc b/src/logging/writers/SQLite.cc index 37e3134659..46d1f17130 100644 --- a/src/logging/writers/SQLite.cc +++ b/src/logging/writers/SQLite.cc @@ -308,7 +308,7 @@ int SQLite::AddParams(Value* val, int pos) if ( j > 0 ) desc.AddRaw(set_separator); - io->Describe(&desc, val->val.set_val.vals[j], fields[pos]->name); + io->Describe(&desc, val->val.set_val.vals[j], fields[pos-1]->name); } desc.RemoveEscapeSequence(set_separator); @@ -330,7 +330,7 @@ int SQLite::AddParams(Value* val, int pos) if ( j > 0 ) desc.AddRaw(set_separator); - io->Describe(&desc, val->val.vector_val.vals[j], fields[pos]->name); + io->Describe(&desc, val->val.vector_val.vals[j], fields[pos-1]->name); } desc.RemoveEscapeSequence(set_separator);