From 55ae7a516126f9f064d8353bf962256b7307590a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 1 Sep 2015 11:13:48 +0200 Subject: Consider md5sum no longer a usable hash The md5sum hash is broken since some time and we should no longer consider it a usable hash. Also update the tests to reflect this. --- apt-pkg/contrib/hashes.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'apt-pkg/contrib/hashes.cc') diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 4481321c4..41a0037cd 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -129,6 +129,13 @@ APT_PURE bool HashString::empty() const /*{{{*/ return (Type.empty() || Hash.empty()); } /*}}}*/ +APT_PURE bool HashString::usable() const /*{{{*/ +{ + return ( + (Type != "Checksum-FileSize") && + (Type != "MD5Sum") + ); +} std::string HashString::toStr() const /*{{{*/ { return Type + ":" + Hash; @@ -151,10 +158,10 @@ bool HashStringList::usable() const /*{{{*/ std::string const forcedType = _config->Find("Acquire::ForceHash", ""); if (forcedType.empty() == true) { - // FileSize alone isn't usable - for (std::vector::const_iterator hs = list.begin(); hs != list.end(); ++hs) - if (hs->HashType() != "Checksum-FileSize") - return true; + // See if there is at least one usable hash + for (auto const &hs: list) + if (hs.usable()) + return true; return false; } return find(forcedType) != NULL; -- cgit v1.2.3