#795 Invalid data passed to Time::Local causes global destruction

open
nobody
5
9 hours ago
2010-04-21
Cory McIntire
No

This is a second submission of this bug at the request of 'eldy': ID 1981437

Second '84' out of range 0..59 at /usr/local/cpanel/base/awstats.pl line 1116

--- awstats-6.7/wwwroot/cgi-bin/awstats.pl.orig 2008-06-01 06:58:26.000000000 -0500
+++ awstats-6.7/wwwroot/cgi-bin/awstats.pl 2008-06-01 07:01:11.000000000 -0500
@@ -1112,8 +1112,16 @@

------------------------------------------------------------------------------

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); }
+
+ # skip unneeded calculations if its the same
+ if ($[0] == $[1]) { return $SessionsRange[0]; }
+
+ eval {
+ #safety to prevent Time::Local causing termination on invalid data
+ #Ex: Second '84' out of range 0..59 at /usr/local/cpanel/base/awstats.pl line 1117
+ if ($[0] =~ /$regdate/o) { $starttime = Time::Local::timelocal($6,$5,$4,$3,$2-1,$1); }
+ if ($
[1] =~ /$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); }
if ($delay <= 30) { return $SessionsRange[0]; }

The raw sub:
sub GetSessionRange {
my $starttime = my $endtime;

skip unneeded calculations if its the same

if ($[0] == $[1]) { return $SessionsRange[0]; }

eval {

safety to prevent Time::Local causing termination on invalid data

Ex: Second '84' out of range 0..59 at /usr/local/cpanel/base/awstats.pl line 1117

if ($[0] =~ /$regdate/o) { $starttime = Time::Local::timelocal($6,$5,$4,$3,$2-1,$1); }
if ($
[1] =~ /$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); }
if ($delay <= 30) { return $SessionsRange[0]; }
if ($delay <= 120) { return $SessionsRange[1]; }
if ($delay <= 300) { return $SessionsRange[2]; }
if ($delay <= 900) { return $SessionsRange[3]; }
if ($delay <= 1800) { return $SessionsRange[4]; }
if ($delay <= 3600) { return $SessionsRange[5]; }
return $SessionsRange[6];
}

We still patch this way to resolve this issue.

Thank you,

Discussion

  • Chris Larsen
    Chris Larsen
    2010-04-30

    Hi Cory, looks like Eldy had fixed this in 6.96. Could you try out the CVS file and see if it's working properly? Thanks.