mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Fix WriterBackend::WriterInfo serialization, reenable ascii start/end tags.
Instantiations of WriterInfo in RemoteSerializer::ProcessLogCreateWriter() would leave the network_time member uninitialized which could later cause localtime_r() calls in Ascii::Timestamp() to return a null pointer due to the bizarre input and giving that to strftime() causes it to segfault.
This commit is contained in:
parent
f2e60a76a8
commit
9b0fe744f2
3 changed files with 5 additions and 10 deletions
|
@ -76,6 +76,7 @@ bool WriterBackend::WriterInfo::Read(SerializationFormat* fmt)
|
||||||
if ( ! (fmt->Read(&tmp_path, "path") &&
|
if ( ! (fmt->Read(&tmp_path, "path") &&
|
||||||
fmt->Read(&rotation_base, "rotation_base") &&
|
fmt->Read(&rotation_base, "rotation_base") &&
|
||||||
fmt->Read(&rotation_interval, "rotation_interval") &&
|
fmt->Read(&rotation_interval, "rotation_interval") &&
|
||||||
|
fmt->Read(&network_time, "network_time") &&
|
||||||
fmt->Read(&size, "config_size")) )
|
fmt->Read(&size, "config_size")) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -105,6 +106,7 @@ bool WriterBackend::WriterInfo::Write(SerializationFormat* fmt) const
|
||||||
if ( ! (fmt->Write(path, "path") &&
|
if ( ! (fmt->Write(path, "path") &&
|
||||||
fmt->Write(rotation_base, "rotation_base") &&
|
fmt->Write(rotation_base, "rotation_base") &&
|
||||||
fmt->Write(rotation_interval, "rotation_interval") &&
|
fmt->Write(rotation_interval, "rotation_interval") &&
|
||||||
|
fmt->Write(network_time, "network_time") &&
|
||||||
fmt->Write(size, "config_size")) )
|
fmt->Write(size, "config_size")) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -81,9 +81,9 @@ public:
|
||||||
*/
|
*/
|
||||||
config_map config;
|
config_map config;
|
||||||
|
|
||||||
WriterInfo()
|
WriterInfo() : path(0), rotation_interval(0.0), rotation_base(0.0),
|
||||||
|
network_time(0.0)
|
||||||
{
|
{
|
||||||
path = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WriterInfo(const WriterInfo& other)
|
WriterInfo(const WriterInfo& other)
|
||||||
|
|
|
@ -416,12 +416,6 @@ string Ascii::LogExt()
|
||||||
|
|
||||||
string Ascii::Timestamp(double t)
|
string Ascii::Timestamp(double t)
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
return "2012-01-01-00-00-00";
|
|
||||||
#else
|
|
||||||
// Using the version below leads to occasional crashes at least on Mac OS.
|
|
||||||
// Not sure why, all the function should be thread-safe ...
|
|
||||||
|
|
||||||
time_t teatime = time_t(t);
|
time_t teatime = time_t(t);
|
||||||
|
|
||||||
struct tm tmbuf;
|
struct tm tmbuf;
|
||||||
|
@ -432,7 +426,6 @@ string Ascii::Timestamp(double t)
|
||||||
strftime(tmp, sizeof(tmp), date_fmt, tm);
|
strftime(tmp, sizeof(tmp), date_fmt, tm);
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue