]> git.saurik.com Git - apt.git/commitdiff
make http size check work
authorMichael Vogt <mvo@ubuntu.com>
Mon, 6 Oct 2014 15:42:39 +0000 (17:42 +0200)
committerMichael Vogt <mvo@ubuntu.com>
Mon, 6 Oct 2014 15:42:39 +0000 (17:42 +0200)
1  2 
apt-pkg/acquire-method.cc
apt-pkg/acquire-method.h
methods/http.cc
methods/http.h
methods/https.cc
methods/https.h
methods/server.cc
methods/server.h
test/integration/test-apt-update-expected-size

Simple merge
Simple merge
diff --cc methods/http.cc
index 916fa464f7d79c3c41cb5a1af5eb650eea14aa47,f2a4a4db631add976bcbf36d329a57d45d3304a5..b076e59ccc52f883fb96643acaef39f9d8550aa6
@@@ -653,10 -651,6 +655,12 @@@ bool HttpServerState::Go(bool ToFile, F
         return _error->Errno("write",_("Error writing to output file"));
     }
  
-    if (ExpectedSize > 0 && In.TotalWriten > ExpectedSize)
++   if (ExpectedSize > 0 && File && File->Tell() > ExpectedSize)
++   {
 +      return _error->Error("Writing more data than expected (%llu > %llu)",
-                            In.TotalWriten, ExpectedSize);
++                           File->Tell(), ExpectedSize);
++   }
 +
     // Handle commands from APT
     if (FD_ISSET(STDIN_FILENO,&rfds))
     {
diff --cc methods/http.h
Simple merge
Simple merge
diff --cc methods/https.h
index 2335559fb0e4073020e2ddd53f60b8b57553b0d0,45d1f7f63a94858731e3659fa0742e8fc0ec3622..0387cb9b579764c4615808531630ce4007698145
@@@ -70,10 -69,9 +70,9 @@@ class HttpsMethod : public pkgAcqMetho
  
     public:
     FileFd *File;
 -
 -   HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), Server(NULL), File(NULL)
 +      
-    HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), TotalWritten(0), File(NULL)
++   HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), Server(NULL), TotalWritten(0), File(NULL)
     {
-       File = 0;
        curl = curl_easy_init();
     };
  
index 1b6511c59dc0525bc0b4e8ae116594a9c4bda42c,4a961f454df65bd152e29c75ed04afec920db620..2237379010d809544183a9ae96336ee315ccdf2d
@@@ -609,7 -605,7 +610,10 @@@ int ServerMethod::Loop(
                  QueueBack = Queue;
               }
               else
++               {
++                  Server->Close();
                  Fail(true);
++               }
            }
            break;
         }
Simple merge
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..72812336dec811c9bad76dc939f5ef726e79fd26
new file mode 100755 (executable)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,27 @@@
++#!/bin/sh
++set -e
++
++TESTDIR=$(readlink -f $(dirname $0))
++. $TESTDIR/framework
++
++setupenvironment
++configarchitecture "i386"
++
++insertpackage 'unstable' 'apt' 'all' '1.0'
++
++setupaptarchive --no-update
++changetowebserver
++
++# normal update works fine
++testsuccess aptget update
++
++# append junk at the end of the Packages.gz/Packages
++SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
++echo "1234567890" >> aptarchive/dists/unstable/main/binary-i386/Packages.gz
++echo "1234567890" >> aptarchive/dists/unstable/main/binary-i386/Packages
++NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
++rm -f rootdir/var/lib/apt/lists/localhost*
++testequal "W: Failed to fetch http://localhost:8080/dists/unstable/main/binary-i386/Packages  Writing more data than expected ($NEW_SIZE > $SIZE) [IP: ::1 8080]
++
++E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq
++