From: Laurent Destailleur Date: Fri, 25 Apr 2014 17:32:08 +0000 (+0200) Subject: Fix: #680 Invalid data passed to Time::Local causes global destruction X-Git-Tag: AWSTATS_7_4~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=427628071ab9716e8ad9339f43481b6e998eb317;p=thirdparty%2FAWStats.git Fix: #680 Invalid data passed to Time::Local causes global destruction --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index 44359847..9c1e919f 100755 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -1572,16 +1572,25 @@ sub DateIsValid { # Parameters: $starttime $endtime # Input: None # Output: None -# Return: A string that identify the visit duration range +# Return: A string from $SessionsRange[0..6] that identify the visit duration range #------------------------------------------------------------------------------ sub GetSessionRange { - my $starttime = my $endtime; - if ( shift =~ /$regdate/o ) { - $starttime = Time::Local::timelocal( $6, $5, $4, $3, $2 - 1, $1 ); - } - if ( shift =~ /$regdate/o ) { - $endtime = Time::Local::timelocal( $6, $5, $4, $3, $2 - 1, $1 ); - } + my $param1=shift; + my $param2=shift; + + # skip unneeded calculations if its the same + if ($param1 == $param2) { return $SessionsRange[0]; } + + my $starttime; + my $endtime; + + eval { + #safety to prevent Time::Local causing termination on invalid data + #Ex: Second '84' out of range 0..59 at /xxx/awstats.pl + if ($param1 =~ /$regdate/o) { $starttime = Time::Local::timelocal($6,$5,$4,$3,$2-1,$1); } + if ($param2 =~ /$regdate/o) { $endtime = Time::Local::timelocal($6,$5,$4,$3,$2-1,$1); } + }; + my $delay = $endtime - $starttime; if ($Debug) { debug( "GetSessionRange $endtime - $starttime = $delay", 4 );