Просмотр исходного кода

reenable patchsize limit option for pdiffs

One word: "doh!" Commit f6d4ab9ad8a2cfe52737ab620dd252cf8ceec43d
disabled the check to prevent apt from downloading bigger patches
than the index it tries to patch. Happens rarly of course, but still.
Detected by scan-build complaining about a dead assignment.
To make up for the mistake a test is included as well.
David Kalnischkies лет назад: 11
Родитель
Сommit
c355ea3038
2 измененных файлов с 35 добавлено и 1 удалено
  1. 1 1
      apt-pkg/acquire-item.cc
  2. 34 0
      test/integration/test-pdiff-usage

+ 1 - 1
apt-pkg/acquire-item.cc

@@ -619,7 +619,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)		/*{{{*/
 	 cur != available_patches.end(); ++cur)
 	 cur != available_patches.end(); ++cur)
       patchesSize += cur->patch_size;
       patchesSize += cur->patch_size;
    unsigned long long const sizeLimit = ServerSize * _config->FindI("Acquire::PDiffs::SizeLimit", 100);
    unsigned long long const sizeLimit = ServerSize * _config->FindI("Acquire::PDiffs::SizeLimit", 100);
-   if (false && sizeLimit > 0 && (sizeLimit/100) < patchesSize)
+   if (sizeLimit > 0 && (sizeLimit/100) < patchesSize)
    {
    {
       if (Debug)
       if (Debug)
 	 std::clog << "Need " << patchesSize << " bytes (Limit is " << sizeLimit/100
 	 std::clog << "Need " << patchesSize << " bytes (Limit is " << sizeLimit/100

+ 34 - 0
test/integration/test-pdiff-usage

@@ -180,6 +180,40 @@ SHA256-Patches:
 	testnopackage oldstuff
 	testnopackage oldstuff
 	testequal "$(cat ${PKGFILE}-new)
 	testequal "$(cat ${PKGFILE}-new)
 " aptcache show apt newstuff
 " aptcache show apt newstuff
+
+	msgmsg "Testcase: pdiff patch bigger than index itself: $*"
+	rm -rf rootdir/var/lib/apt/lists
+	cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
+	cp ${PKGFILE}-new aptarchive/Packages
+	compressfile 'aptarchive/Packages'
+	mkdir -p aptarchive/Packages.diff
+	PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
+	diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
+	cat $PATCHFILE | gzip > ${PATCHFILE}.gz
+	PATCHINDEX='aptarchive/Packages.diff/Index'
+	echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
+SHA1-History:
+ 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
+ $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
+SHA1-Patches:
+ 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
+ $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE)000 $(basename $PATCHFILE)
+SHA256-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
+SHA256-History:
+ 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
+ $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
+SHA256-Patches:
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
+ $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE)000 $(basename $PATCHFILE)" > $PATCHINDEX
+	generatereleasefiles '+1hour'
+	signreleasefiles
+	#find aptarchive -name 'Packages*' -type f -delete
+	testsuccess aptget update -o Debug::pkgAcquire::Diffs=1 "$@"
+	cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptgetupdate.output
+	testsuccess grep 'bytes (Limit is' rootdir/tmp/aptgetupdate.output
+	testnopackage oldstuff
+	testequal "$(cat ${PKGFILE}-new)
+" aptcache show apt newstuff
 }
 }
 echo 'Debug::pkgAcquire::Diffs "true";
 echo 'Debug::pkgAcquire::Diffs "true";
 Debug::Acquire::Transaction "true";
 Debug::Acquire::Transaction "true";