Browse Source

Fixed overflow in the calculation of progress percentage for file
allocation and hash check when off_t is 32bit.

Tatsuhiro Tsujikawa 14 năm trước cách đây
mục cha
commit
27974108f0
1 tập tin đã thay đổi với 8 bổ sung4 xóa
  1. 8 4
      src/ConsoleStatCalc.cc

+ 8 - 4
src/ConsoleStatCalc.cc

@@ -311,7 +311,7 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
         << "B"
         << "(";
       if(entry->getTotalLength() > 0) {
-        o << 100*entry->getCurrentLength()/entry->getTotalLength();
+        o << 100LL*entry->getCurrentLength()/entry->getTotalLength();
       } else {
         o << "--";
       }
@@ -337,9 +337,13 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
         << "/"
         << sizeFormatter(entry->getTotalLength())
         << "B"
-        << "("
-        << 100*entry->getCurrentLength()/entry->getTotalLength()
-        << "%)"
+        << "(";
+      if(entry->getTotalLength() > 0) {
+        o << 100LL*entry->getCurrentLength()/entry->getTotalLength();
+      } else {
+        o << "--";
+      }
+      o << "%)"
         << "]";
       if(e->getCheckIntegrityMan()->hasNext()) {
         o << "("