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

closed
nobody
5
2015-02-07
2008-06-01
No

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];

}

Discussion

  • J. Nick Koston

    J. Nick Koston - 2008-06-01

    Logged In: YES
    user_id=2297
    Originator: YES

    Time::Local:: timelocal_nocheck
    also exists

    Time::Local::timegm {
    ..
    croak "Day '$mday' out of range 1..$md" if $mday > $md or $mday < 1;
    croak "Hour '$hour' out of range 0..23" if $hour > 23 or $hour < 0;
    croak "Minute '$min' out of range 0..59" if $min > 59 or $min < 0;
    croak "Second '$sec' out of range 0..59" if $sec > 59 or $sec < 0;
    ..
    }
    However its probably best to handle the invalid data outside of the Time::Local call

     
  • Laurent Destailleur (Eldy)

    The request was closed because date is old.
    Problem might be fixed or patch may be obsolete.

    If this is not true, please resubmit the request.

     
  • Derek Pomery

    Derek Pomery - 2014-04-25

    I'd like to note I ran into this bug yesterday when importing a year's worth of IIS logs (a day at a time) into awstats 7.0 build 1.971.

    The patch as written worked perfectly, and without it I would not have been able to do the import. Thanks!

    IMO this bug should be reopened.

     
  • maxmouse

    maxmouse - 2014-11-10

    the patch submitted here resolved the issue for me as well.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks