diff options
-rw-r--r-- | apt-pkg/deb/debindexfile.cc | 2 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.h | 11 | ||||
-rwxr-xr-x | test/integration/test-apt-translation-has-no-packages | 41 |
3 files changed, 53 insertions, 1 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index eee758b7a..a0dd15cd8 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -525,7 +525,7 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const if (FileExists(TranslationFile)) { FileFd Trans(TranslationFile,FileFd::ReadOnly, FileFd::Extension); - debListParser TransParser(&Trans); + debTranslationsParser TransParser(&Trans); if (_error->PendingError() == true) return false; diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index baace79fe..3b6963211 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -106,4 +106,15 @@ class debListParser : public pkgCacheGenerator::ListParser APT_HIDDEN unsigned char ParseMultiArch(bool const showErrors); }; +class debTranslationsParser : public debListParser +{ + public: + // a translation can never be a real package + virtual std::string Architecture() { return ""; } + virtual std::string Version() { return ""; } + + debTranslationsParser(FileFd *File, std::string const &Arch = "") + : debListParser(File, Arch) {}; +}; + #endif diff --git a/test/integration/test-apt-translation-has-no-packages b/test/integration/test-apt-translation-has-no-packages new file mode 100755 index 000000000..bb2353a33 --- /dev/null +++ b/test/integration/test-apt-translation-has-no-packages @@ -0,0 +1,41 @@ +#!/bin/sh +# +# Due to corruption (local or network) a user might end up with a +# Translation-$lang file on disk that is actually a Packages file. In this +# case apt used to generate invalid package versions out of the +# Translation-$lang file (i.e. apt-cache policy foo) would show a version +# comming out of a Translation file. Downloading this versions fails as +# there is no acquire method available for the package +# +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture "amd64" + +if [ ! -x ${BUILDDIRECTORY}/apt ]; then + msgmsg "No ${BUILDDIRECTORY}/apt" + msgskip + exit 0 +fi + +buildsimplenativepackage 'foo' 'all' '1.0' +setupaptarchive + +APTARCHIVE=$(readlink -f ./aptarchive) + +# corrupt the Translation-en file to look like a regular Packages file +rm rootdir/var/cache/apt/*.bin +cp $APTARCHIVE/dists/unstable/main/binary-amd64/Packages \ + rootdir/var/lib/apt/lists/*Translation-en + +# ensure that there is no Version for the package foo generated out of +# the corrupted Translation-en file +testequal "foo: + Installed: (none) + Candidate: 1.0 + Version table: + 1.0 0 + 500 file:$APTARCHIVE/ unstable/main amd64 Packages" aptcache policy foo |