vdradmin-am division by zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I found a bug in vdradmin-am 3.4.6beta2 that always crashed my vdradmin.pl.
In the "prog_summary" section, there is a calculation of how much percent of 
the event is already passed.
But when the start-time and the end-time of that event are the same than the 
following code will result in an "Division by Zero":
Line 3989 of vdradmin.pl:

percent => int(($now - $event->{start})/($event->{stop} - 
$event->{start})*100),

This should be checked like this:

percent => ($event->{stop} - $event->{start} > 0) ? (int(($now - 
$event->{start})/($event->{stop} - $event->{start})*100)) : 0,

here is a patch:

============= patch begin ==============
@@ -3986,7 +3986,7 @@
                     stop        => my_strftime("%H:%M",  $event->{stop}),
                     event_start => $event->{start},
                     show_percent => $event->{start} <= $now && $now <= 
$event->{stop} ? "1" : undef,
-                    percent     => int(($now - $event->{start}) / 
($event->{stop} - $event->{start}) * 100),
+                    percent     => ($event->{stop} - $event->{start} > 0) ? 
(int(($now - $event->{start}) / ($event->{stop} - $event->{start}) * 100)) : 
0,
                     elapsed_min => int(($now - $event->{start}) / 60),
                     length_min  => int(($event->{stop} - $event->{start}) / 
60),
                     title       => $displaytitle,
============= patch end ==============

Greets
Patrick

-- 
     There are only 10 kind of people who understand binary digits:
     Those who do - Those who don't... 



[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux