[vdr] vdradmin-am division by zero

Patrick Maier maierp at informatik.tu-muenchen.de
Thu Jun 8 14:25:27 CEST 2006


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... 




More information about the vdr mailing list