mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 00:28:21 +00:00
Merge branch 'topic/petiepooo/localtime_r-segv' of https://github.com/petiepooo/bro
Added one more failure check for a zero interval.
This commit is contained in:
commit
b4c0f217c0
3 changed files with 22 additions and 4 deletions
5
CHANGES
5
CHANGES
|
@ -1,4 +1,9 @@
|
||||||
|
|
||||||
|
2.3-599 | 2015-03-25 10:14:57 -0700
|
||||||
|
|
||||||
|
* Add defensive checks in code to calculate log rotation intervals.
|
||||||
|
(Pete Nelson).
|
||||||
|
|
||||||
2.3-597 | 2015-03-23 12:50:04 -0700
|
2.3-597 | 2015-03-23 12:50:04 -0700
|
||||||
|
|
||||||
* DTLS analyzer. (Johanna Amann)
|
* DTLS analyzer. (Johanna Amann)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.3-597
|
2.3-599
|
||||||
|
|
19
src/util.cc
19
src/util.cc
|
@ -1352,13 +1352,23 @@ double parse_rotate_base_time(const char* rotate_base_time)
|
||||||
|
|
||||||
double calc_next_rotate(double current, double interval, double base)
|
double calc_next_rotate(double current, double interval, double base)
|
||||||
{
|
{
|
||||||
|
if ( ! interval )
|
||||||
|
{
|
||||||
|
reporter->Error("calc_next_rotate(): interval is zero, falling back to 24hrs");
|
||||||
|
interval = 86400;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate start of day.
|
// Calculate start of day.
|
||||||
time_t teatime = time_t(current);
|
time_t teatime = time_t(current);
|
||||||
|
|
||||||
struct tm t;
|
struct tm t;
|
||||||
t = *localtime_r(&teatime, &t);
|
if ( ! localtime_r(&teatime, &t) )
|
||||||
t.tm_hour = t.tm_min = t.tm_sec = 0;
|
{
|
||||||
double startofday = mktime(&t);
|
reporter->Error("calc_next_rotate(): failure processing current time (%.6f)", current);
|
||||||
|
|
||||||
|
// fall back to the method used if no base time is given
|
||||||
|
base = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if ( base < 0 )
|
if ( base < 0 )
|
||||||
// No base time given. To get nice timestamps, we round
|
// No base time given. To get nice timestamps, we round
|
||||||
|
@ -1366,6 +1376,9 @@ double calc_next_rotate(double current, double interval, double base)
|
||||||
return floor(current / interval) * interval
|
return floor(current / interval) * interval
|
||||||
+ interval - current;
|
+ interval - current;
|
||||||
|
|
||||||
|
t.tm_hour = t.tm_min = t.tm_sec = 0;
|
||||||
|
double startofday = mktime(&t);
|
||||||
|
|
||||||
// current < startofday + base + i * interval <= current + interval
|
// current < startofday + base + i * interval <= current + interval
|
||||||
return startofday + base +
|
return startofday + base +
|
||||||
ceil((current - startofday - base) / interval) * interval -
|
ceil((current - startofday - base) / interval) * interval -
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue