[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#280844: Another patch to fix downloaded files corruption



Well,
  I have no idea what I'm doing wrong.  So I wrote something what looks more 
reasonable than original Geller's patch to me.  Am I really only one who cares
that apt is corrupting package it downloads ?  This time tetex-base_3.0.orig.tar.gz
is corrupted on redownload as its last byte is CR (0D) (it is replaced with 'H',
see previous messages in this bugreport and bug 290694).

  Can sombody at least tell me why this important data corrupting bug is 
ignored for more than year?
						Thanks,
							Petr Vandrovec


diff -urN apt-0.6.42/debian/changelog apt-0.6.42.fix/debian/changelog
--- apt-0.6.42/debian/changelog	2005-10-20 11:33:43.000000000 +0200
+++ apt-0.6.42.fix/debian/changelog	2005-10-22 16:59:15.000000000 +0200
@@ -1,3 +1,9 @@
+apt (0.6.42.1) unstable; urgency=low
+
+  * Fix corruption of downloaded packages (closes: #280844, #290694).
+
+ -- Petr Vandrovec <petr@vandrovec.name>  Sat, 22 Oct 2005 17:00:00 +0200
+
 apt (0.6.42) unstable; urgency=low
 
   * apt-pkg/cdrom.cc:
diff -urN apt-0.6.42/methods/http.cc apt-0.6.42.fix/methods/http.cc
--- apt-0.6.42/methods/http.cc	2005-10-19 21:19:09.000000000 +0200
+++ apt-0.6.42.fix/methods/http.cc	2005-10-22 16:58:15.000000000 +0200
@@ -204,28 +204,23 @@
       if (Buf[I%Size] != '\n')
 	 continue;
       ++I;
-      if (I < InP  && Buf[I%Size] == '\r')
-         ++I;
       
       if (Single == false)
       {
-	 if (Buf[I%Size] != '\n')
-	    continue;
-         ++I;
          if (I < InP  && Buf[I%Size] == '\r')
             ++I;
+         if (I >= InP || Buf[I%Size] != '\n')
+            continue;
+         ++I;
       }
       
-      if (I > InP)
-	 I = InP;
-      
       Data = "";
       while (OutP < I)
       {
 	 unsigned long Sz = LeftWrite();
 	 if (Sz == 0)
 	    return false;
-	 if (I - OutP < LeftWrite())
+	 if (I - OutP < Sz)
 	    Sz = I - OutP;
 	 Data += string((char *)(Buf + (OutP%Size)),Sz);
 	 OutP += Sz;



Reply to: