Procházet zdrojové kódy

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

Tatsuhiro Tsujikawa před 14 roky
rodič
revize
27974108f0
1 změnil soubory, kde provedl 8 přidání a 4 odebrání
  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 << "("