From 8a8feb29265b3dfc27f82072563a641a7976752a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 30 Jul 2007 17:47:05 +0200 Subject: * apt-pkg/acquire-item.{cc,h}: - rename "hash" into ExpectedHash in pkgAcqFile, pkgAcqIndex - add missing HashSum() call to class pkgAcqIndex - use the data provided by acquire-method (and send via the {SHA256,SHA1,MD5Sum}-Hash tag when comparing the hash, this avoids calculating the hash twice (just like old libapt) * apt-pkg/acquire-method.cc: - send MD5Sum-Hash tag to libapt to be consistant with HashString::SupportedHashes() * apt-pkg/acquire-worker.cc: - check with "Owner->HashSum().HashType()" what hash the frontend is expecting and pass it to pkgAcquireItem::Done() in the new HashString format - add some debugging output * apt-pkg/contrib/hashes.cc: - fix off-by-one error when constructing a HashString from a single input string * apt-pkg/contrib/hashes.h: - add "HashType()" method * apt-pkg/init.h, apt-pkg/makefile, methods/makefile: - break ABI --- apt-pkg/acquire-item.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'apt-pkg/acquire-item.cc') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index a7132ce1d..c48502bb9 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -641,7 +641,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash, std::cerr << " Expected Hash: " << ExpectedHash.toStr() << std::endl; } - if (!ExpectedHash.empty() && !ExpectedHash.VerifyFile(DestFile)) + if (!ExpectedHash.empty() && ExpectedHash.toStr() != Hash) { Status = StatAuthError; ErrorText = _("Hash Sum mismatch"); @@ -1296,11 +1296,11 @@ bool pkgAcqArchive::QueueNext() string PkgFile = Parse.FileName(); if(Parse.SHA256Hash() != "") - hash = HashString("SHA256", Parse.SHA256Hash()); + ExpectedHash = HashString("SHA256", Parse.SHA256Hash()); else if (Parse.SHA1Hash() != "") - hash = HashString("SHA1", Parse.SHA1Hash()); + ExpectedHash = HashString("SHA1", Parse.SHA1Hash()); else - hash = HashString("MD5Sum", Parse.MD5Hash()); + ExpectedHash = HashString("MD5Sum", Parse.MD5Hash()); if (PkgFile.empty() == true) return _error->Error(_("The package index files are corrupted. No Filename: " "field for package %s."), @@ -1394,7 +1394,7 @@ void pkgAcqArchive::Done(string Message,unsigned long Size,string CalcHash, } // Check the hash - if(!hash.VerifyFile(DestFile)) + if(ExpectedHash.toStr() != CalcHash) { Status = StatError; ErrorText = _("Hash Sum mismatch"); @@ -1492,10 +1492,10 @@ void pkgAcqArchive::Finished() // AcqFile::pkgAcqFile - Constructor /*{{{*/ // --------------------------------------------------------------------- /* The file is added to the queue */ -pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string MD5, +pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash, unsigned long Size,string Dsc,string ShortDesc, const string &DestDir, const string &DestFilename) : - Item(Owner), hash(MD5) + Item(Owner), ExpectedHash(Hash) { Retries = _config->FindI("Acquire::Retries",0); @@ -1537,8 +1537,8 @@ void pkgAcqFile::Done(string Message,unsigned long Size,string CalcHash, { Item::Done(Message,Size,CalcHash,Cnf); - // Check the md5 - if(!hash.VerifyFile(DestFile)) + // Check the hash + if(ExpectedHash.toStr() != CalcHash) { Status = StatError; ErrorText = "Hash Sum mismatch"; -- cgit v1.2.3-70-g09d2