diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2011-06-29 19:21:34 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2011-06-29 19:21:34 +0200 |
commit | 8f8ed8f4e50fd98aa43ee69971cac8bda55760f1 (patch) | |
tree | 79dbb2f29aca55db49f8e7213094a8423caa343e /apt-pkg/acquire-item.cc | |
parent | d953d210bb54accb416f2144104b79dcd29198ba (diff) | |
parent | 6f747894998e10649d0237fe5f7b9b85a5266f1f (diff) |
merge with debian-experimental 0.8.16~exp2 release
Diffstat (limited to 'apt-pkg/acquire-item.cc')
-rw-r--r-- | apt-pkg/acquire-item.cc | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 6785b4e1b..d790bd898 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -271,6 +271,14 @@ void pkgAcqSubIndex::Done(string Message,unsigned long Size,string Md5Hash, /*{{ string FinalFile = _config->FindDir("Dir::State::lists")+URItoFileName(Desc.URI); + /* Downloaded invalid transindex => Error (LP: #346386) (Closes: #627642) */ + indexRecords SubIndexParser; + if (FileExists(DestFile) == true && !SubIndexParser.Load(DestFile)) { + Status = StatError; + ErrorText = SubIndexParser.ErrorText; + return; + } + // sucess in downloading the index // rename the index if(Debug) @@ -894,6 +902,30 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash, ReportMirrorFailure("HashChecksumFailure"); return; } + + /* Verify the index file for correctness (all indexes must + * have a Package field) (LP: #346386) (Closes: #627642) */ + { + FileFd fd(DestFile, FileFd::ReadOnly); + pkgTagSection sec; + pkgTagFile tag(&fd); + + // Only test for correctness if the file is not empty (empty is ok) + if (fd.Size() > 0) { + if (_error->PendingError() || !tag.Step(sec)) { + Status = StatError; + _error->DumpErrors(); + Rename(DestFile,DestFile + ".FAILED"); + return; + } else if (!sec.Exists("Package")) { + Status = StatError; + ErrorText = ("Encountered a section with no Package: header"); + Rename(DestFile,DestFile + ".FAILED"); + return; + } + } + } + // Done, move it into position string FinalFile = _config->FindDir("Dir::State::lists"); FinalFile += URItoFileName(RealURI); @@ -1330,6 +1362,16 @@ void pkgAcqMetaIndex::AuthDone(string Message) /*{{{*/ /*}}}*/ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ { +#if 0 + /* Reject invalid, existing Release files (LP: #346386) (Closes: #627642) + * FIXME: Disabled; it breaks unsigned repositories without hashes */ + if (!verify && FileExists(DestFile) && !MetaIndexParser->Load(DestFile)) + { + Status = StatError; + ErrorText = MetaIndexParser->ErrorText; + return; + } +#endif for (vector <struct IndexTarget*>::const_iterator Target = IndexTargets->begin(); Target != IndexTargets->end(); Target++) @@ -1493,6 +1535,12 @@ void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) LookupTag(Message,"Message").c_str()); RunScripts("APT::Update::Auth-Failure"); return; + } else if (LookupTag(Message,"Message").find("NODATA") != string::npos) { + /* Invalid signature file, reject (LP: #346386) (Closes: #627642) */ + _error->Error(_("GPG error: %s: %s"), + Desc.Description.c_str(), + LookupTag(Message,"Message").c_str()); + return; } else { _error->Warning(_("GPG error: %s: %s"), Desc.Description.c_str(), @@ -1682,6 +1730,8 @@ bool pkgAcqArchive::QueueNext() string PkgFile = Parse.FileName(); if (ForceHash.empty() == false) { + if(stringcasecmp(ForceHash, "sha512") == 0) + ExpectedHash = HashString("SHA512", Parse.SHA512Hash()); if(stringcasecmp(ForceHash, "sha256") == 0) ExpectedHash = HashString("SHA256", Parse.SHA256Hash()); else if (stringcasecmp(ForceHash, "sha1") == 0) @@ -1692,7 +1742,9 @@ bool pkgAcqArchive::QueueNext() else { string Hash; - if ((Hash = Parse.SHA256Hash()).empty() == false) + if ((Hash = Parse.SHA512Hash()).empty() == false) + ExpectedHash = HashString("SHA512", Hash); + else if ((Hash = Parse.SHA256Hash()).empty() == false) ExpectedHash = HashString("SHA256", Hash); else if ((Hash = Parse.SHA1Hash()).empty() == false) ExpectedHash = HashString("SHA1", Hash); |