# HG changeset patch # User masneyb # Date 1060048443 0 # Node ID 290d00853950ad13773b1b3e075050c5e7ee46eb # Parent 41af60bc1f8875547d2f8f38ea8996359be6b67e 2003-8-4 Brian Masney * src/gtk/transfer.c (update_file_status) - fix possible division by 0 diff -r 41af60bc1f88 -r 290d00853950 ChangeLog --- a/ChangeLog Tue Aug 05 01:40:49 2003 +0000 +++ b/ChangeLog Tue Aug 05 01:54:03 2003 +0000 @@ -1,3 +1,6 @@ +2003-8-4 Brian Masney + * src/gtk/transfer.c (update_file_status) - fix possible division by 0 + 2003-8-4 Brian Masney * src/gtk/gftp-gtk.c (CreateMenus) - on startup, select the proper ASCII/binary radio button (looks like an old bug!) @@ -1430,7 +1433,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.126 2003/08/05 01:40:47 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.127 2003/08/05 01:54:02 masneyb Exp $ tags * debian/* - updated files from Debian maintainer diff -r 41af60bc1f88 -r 290d00853950 src/gtk/transfer.c --- a/src/gtk/transfer.c Tue Aug 05 01:40:49 2003 +0000 +++ b/src/gtk/transfer.c Tue Aug 05 01:54:03 2003 +0000 @@ -1293,7 +1293,7 @@ { char totstr[100], dlstr[100], gotstr[50], ofstr[50]; int hours, mins, secs, pcent, st; - off_t remaining_secs; + unsigned long remaining_secs, lkbs; gftp_file * tempfle; struct timeval tv; @@ -1303,8 +1303,10 @@ gettimeofday (&tv, NULL); remaining_secs = (tdata->total_bytes - tdata->trans_bytes - tdata->resumed_bytes) / 1024; - if (tdata->kbs > 0) - remaining_secs /= (off_t) tdata->kbs; + + lkbs = (unsigned long) tdata->kbs; + if (lkbs > 0) + remaining_secs /= lkbs; hours = remaining_secs / 3600; remaining_secs -= hours * 3600; @@ -1318,8 +1320,9 @@ return; } - pcent = (int) ((double) (tdata->trans_bytes + tdata->resumed_bytes) / (double) tdata->total_bytes * 100.0); - if (pcent < 0 || pcent > 100) + if ((double) tdata->total_bytes > 0) + pcent = (int) ((double) (tdata->trans_bytes + tdata->resumed_bytes) / (double) tdata->total_bytes * 100.0); + else pcent = 0; g_snprintf (totstr, sizeof (totstr), @@ -1338,8 +1341,10 @@ if (tdata->curfle->next != NULL) { remaining_secs = (tempfle->size - tdata->curtrans - tdata->curresumed) / 1024; - if (tdata->kbs > 0) - remaining_secs /= (off_t) tdata->kbs; + + lkbs = (unsigned long) tdata->kbs; + if (lkbs > 0) + remaining_secs /= lkbs; hours = remaining_secs / 3600; remaining_secs -= hours * 3600;