]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Fix: #680 Invalid data passed to Time::Local causes global destruction
authorLaurent Destailleur <eldy@destailleur.fr>
Fri, 25 Apr 2014 17:32:08 +0000 (19:32 +0200)
committerLaurent Destailleur <eldy@destailleur.fr>
Fri, 25 Apr 2014 17:32:08 +0000 (19:32 +0200)
wwwroot/cgi-bin/awstats.pl

index 4435984711353a7595ebf78215786fb2f83ee532..9c1e919fa4c3a3c7e5c00fb4c2b5590d60f11fb4 100755 (executable)
@@ -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 );