diff -Nru apt-1.0.9.7ubuntu4/debian/changelog apt-1.0.9.7ubuntu4.1/debian/changelog --- apt-1.0.9.7ubuntu4/debian/changelog 2015-04-07 10:30:54.000000000 +0000 +++ apt-1.0.9.7ubuntu4.1/debian/changelog 2015-06-10 14:11:13.000000000 +0000 @@ -1,3 +1,12 @@ +apt (1.0.9.7ubuntu4.1) vivid-proposed; urgency=low + + * test/integration/test-apt-download-progress: + - disable as its too unreliable + * Fix endless loop in apt-get update that can cause disk fillup + LP: #1445239 + + -- Michael Vogt Wed, 10 Jun 2015 16:09:44 +0200 + apt (1.0.9.7ubuntu4) vivid; urgency=medium [ Michael Vogt ] diff -Nru apt-1.0.9.7ubuntu4/methods/http.cc apt-1.0.9.7ubuntu4.1/methods/http.cc --- apt-1.0.9.7ubuntu4/methods/http.cc 2015-04-07 10:30:54.000000000 +0000 +++ apt-1.0.9.7ubuntu4.1/methods/http.cc 2015-06-10 14:10:35.000000000 +0000 @@ -443,7 +443,7 @@ else if (JunkSize != 0) In.Limit(JunkSize); else - In.Limit(Size - StartPos); + In.Limit(DownloadSize); // Just transfer the whole block. do diff -Nru apt-1.0.9.7ubuntu4/methods/server.cc apt-1.0.9.7ubuntu4.1/methods/server.cc --- apt-1.0.9.7ubuntu4/methods/server.cc 2015-04-07 10:30:54.000000000 +0000 +++ apt-1.0.9.7ubuntu4.1/methods/server.cc 2015-06-10 14:10:35.000000000 +0000 @@ -164,15 +164,22 @@ Encoding = Stream; HaveContent = true; - unsigned long long * SizePtr = &Size; + unsigned long long * DownloadSizePtr = &DownloadSize; if (Result == 416) - SizePtr = &JunkSize; + DownloadSizePtr = &JunkSize; - *SizePtr = strtoull(Val.c_str(), NULL, 10); - if (*SizePtr >= std::numeric_limits::max()) + *DownloadSizePtr = strtoull(Val.c_str(), NULL, 10); + if (*DownloadSizePtr >= std::numeric_limits::max()) return _error->Errno("HeaderLine", _("The HTTP server sent an invalid Content-Length header")); - else if (*SizePtr == 0) + else if (*DownloadSizePtr == 0) HaveContent = false; + + // On partial content (206) the Content-Length less than the real + // size, so do not set it here but leave that to the Content-Range + // header instead + if(Result != 206 && Size == 0) + Size = DownloadSize; + return true; } @@ -193,6 +200,9 @@ return _error->Error(_("The HTTP server sent an invalid Content-Range header")); if ((unsigned long long)StartPos > Size) return _error->Error(_("This HTTP server has broken range support")); + + // figure out what we will download + DownloadSize = Size - StartPos; return true; } diff -Nru apt-1.0.9.7ubuntu4/methods/server.h apt-1.0.9.7ubuntu4.1/methods/server.h --- apt-1.0.9.7ubuntu4/methods/server.h 2015-04-07 10:30:54.000000000 +0000 +++ apt-1.0.9.7ubuntu4.1/methods/server.h 2015-06-10 14:10:35.000000000 +0000 @@ -34,7 +34,8 @@ char Code[360]; // These are some statistics from the last parsed header lines - unsigned long long Size; // size of the usable content (aka: the file) + unsigned long long Size; // total size of the usable content (aka: the file) + unsigned long long DownloadSize; // size we actually download (can be smaller than Size if we have partial content) unsigned long long JunkSize; // size of junk content (aka: server error pages) unsigned long long StartPos; time_t Date; diff -Nru apt-1.0.9.7ubuntu4/test/integration/test-apt-download-progress apt-1.0.9.7ubuntu4.1/test/integration/test-apt-download-progress --- apt-1.0.9.7ubuntu4/test/integration/test-apt-download-progress 2015-04-07 10:30:54.000000000 +0000 +++ apt-1.0.9.7ubuntu4.1/test/integration/test-apt-download-progress 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -#!/bin/sh -# -# ensure downloading sends progress as a regression test for commit 9127d7ae -# -set -e - -TESTDIR=$(readlink -f $(dirname $0)) -. $TESTDIR/framework - -setupenvironment -changetohttpswebserver - -assertprogress() { - T="$1" - testsuccess grep "dlstatus:1:0:Retrieving file 1 of 1" "$T" - if ! egrep -q "dlstatus:1:[0-9]{1,2}\.(.*):Retrieving file 1 of 1" "$T"; then - cat "$T" - msgfail "Failed to detect download progress" - fi - testsuccess grep "dlstatus:1:100:Retrieving file 1 of 1" "$T" - #cat $T -} - -# we need to ensure the file is reasonable big so that apt has a chance to -# actually report progress - but not too big to ensure its not delaying the -# test too much -TESTFILE=testfile.big -testsuccess dd if=/dev/zero of=./aptarchive/$TESTFILE bs=800k count=1 - -msgtest 'download progress works via' 'http' -printf '\n' -exec 3> apt-progress.log -testsuccess apthelper download-file "http://localhost:8080/$TESTFILE" http-$TESTFILE -o APT::Status-Fd=3 -o Acquire::http::Dl-Limit=300 -assertprogress apt-progress.log - -msgtest 'download progress works via' 'https' -printf '\n' -exec 3> apt-progress.log -testsuccess apthelper download-file "https://localhost:4433/$TESTFILE" https-$TESTFILE -o APT::Status-Fd=3 -o Acquire::https::Dl-Limit=300 -assertprogress apt-progress.log - -# cleanup -rm -f apt-progress*.log diff -Nru apt-1.0.9.7ubuntu4/test/integration/test-bug-lp1445239-download-loop apt-1.0.9.7ubuntu4.1/test/integration/test-bug-lp1445239-download-loop --- apt-1.0.9.7ubuntu4/test/integration/test-bug-lp1445239-download-loop 1970-01-01 00:00:00.000000000 +0000 +++ apt-1.0.9.7ubuntu4.1/test/integration/test-bug-lp1445239-download-loop 2015-06-10 14:10:50.000000000 +0000 @@ -0,0 +1,29 @@ +#!/bin/sh +# +# this is a regression test for LP: #1445239 where a partial download can +# trigger an endless hang of the download method +# + +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' + +changetowebserver +webserverconfig 'aptwebserver::support::range' 'true' + +TESTFILE='aptarchive/testfile' +dd if=/dev/zero of=$TESTFILE bs=100k count=1 2>/dev/null + +DOWNLOADLOG='rootdir/tmp/testdownloadfile.log' + +TARGET=testfile-downloaded +dd if=/dev/zero of=$TARGET bs=99k count=1 2>/dev/null +if ! downloadfile http://localhost:8080/testfile "$TARGET" > "$DOWNLOADLOG"; then + cat >&2 "$DOWNLOADLOG" + msgfail +else + msgpass +fi diff -Nru apt-1.0.9.7ubuntu4/test/interactive-helper/aptwebserver.cc apt-1.0.9.7ubuntu4.1/test/interactive-helper/aptwebserver.cc --- apt-1.0.9.7ubuntu4/test/interactive-helper/aptwebserver.cc 2015-04-07 10:30:54.000000000 +0000 +++ apt-1.0.9.7ubuntu4.1/test/interactive-helper/aptwebserver.cc 2015-06-10 14:10:50.000000000 +0000 @@ -654,13 +654,15 @@ if (filesize > filestart) { data.Skip(filestart); - std::ostringstream contentlength; - contentlength << "Content-Length: " << (filesize - filestart); - headers.push_back(contentlength.str()); + // make sure to send content-range before conent-length + // as regression test for LP: #1445239 std::ostringstream contentrange; contentrange << "Content-Range: bytes " << filestart << "-" << filesize - 1 << "/" << filesize; headers.push_back(contentrange.str()); + std::ostringstream contentlength; + contentlength << "Content-Length: " << (filesize - filestart); + headers.push_back(contentlength.str()); sendHead(client, 206, headers); if (sendContent == true) sendFile(client, headers, data);