diff options
author | Erik Fonnesbeck <efonnes@gmail.com> | 2010-12-16 17:45:56 -0700 |
---|---|---|
committer | Erik Fonnesbeck <efonnes@gmail.com> | 2010-12-16 17:45:56 -0700 |
commit | f444c3965cc13acc02ea028a528dcfff2c24d2ab (patch) | |
tree | a9456c3fc363c814d88bd808d067a17c80eb3b7e | |
parent | 979c578374cfaf9deb7be02b7a9db6a92807c360 (diff) | |
download | pfsense-f444c3965cc13acc02ea028a528dcfff2c24d2ab.zip pfsense-f444c3965cc13acc02ea028a528dcfff2c24d2ab.tar.gz |
Prevent division by zero if the file size is zero.
-rw-r--r-- | etc/inc/pfsense-utils.inc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 8501df1..098b3c8 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1460,8 +1460,11 @@ function read_body($ch, $string) { global $fout, $file_size, $downloaded, $sendto, $static_status, $static_output, $lastseen; $length = strlen($string); $downloaded += intval($length); - $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0); - $downloadProgress = 100 - $downloadProgress; + if($file_size > 0) { + $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0); + $downloadProgress = 100 - $downloadProgress; + } else + $downloadProgress = 0; if($lastseen <> $downloadProgress and $downloadProgress < 101) { if($sendto == "status") { $tostatus = $static_status . $downloadProgress . "%"; |