Parcourir la source

* apt-pkg/acquire.cc:
- fix potential divide-by-zero

Michael Vogt il y a 15 ans
Parent
commit
c033d41504
2 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 3 1
      apt-pkg/acquire.cc
  2. 2 0
      debian/changelog

+ 3 - 1
apt-pkg/acquire.cc

@@ -849,7 +849,9 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
 
 
       char msg[200];
       char msg[200];
       long i = CurrentItems < TotalItems ? CurrentItems + 1 : CurrentItems;
       long i = CurrentItems < TotalItems ? CurrentItems + 1 : CurrentItems;
-      unsigned long long const ETA = (TotalBytes - CurrentBytes) / CurrentCPS;
+      unsigned long long ETA = 0;
+      if(CurrentCPS > 0)
+         ETA = (TotalBytes - CurrentBytes) / CurrentCPS;
 
 
       // only show the ETA if it makes sense
       // only show the ETA if it makes sense
       if (ETA > 0 && ETA < 172800 /* two days */ )
       if (ETA > 0 && ETA < 172800 /* two days */ )

+ 2 - 0
debian/changelog

@@ -10,6 +10,8 @@ apt (0.8.16~exp5) experimental; urgency=low
   * apt-pkg/acquire-item.{cc,h}:
   * apt-pkg/acquire-item.{cc,h}:
     - do not check for a "Package" tag in optional index targets
     - do not check for a "Package" tag in optional index targets
       like the translations index
       like the translations index
+  * apt-pkg/acquire.cc:
+    - fix potential divide-by-zero
 
 
  -- Michael Vogt <mvo@debian.org>  Fri, 05 Aug 2011 10:57:08 +0200
  -- Michael Vogt <mvo@debian.org>  Fri, 05 Aug 2011 10:57:08 +0200