summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2015-09-01 11:13:48 +0200
committerMichael Vogt <mvo@ubuntu.com>2015-09-01 11:29:49 +0200
commit55ae7a516126f9f064d8353bf962256b7307590a (patch)
tree14c91251fa81c61c4ab26994036213b6ee24f61c /apt-pkg
parent226c0f64d46019d675840b16bd44ff985b45ad0f (diff)
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.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/hashes.cc15
-rw-r--r--apt-pkg/contrib/hashes.h1
2 files changed, 12 insertions, 4 deletions
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<HashString>::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;
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index 0e6ff9ef1..74024befd 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -68,6 +68,7 @@ class HashString
// helper
std::string toStr() const; // convert to str as "type:hash"
bool empty() const;
+ bool usable() const;
bool operator==(HashString const &other) const;
bool operator!=(HashString const &other) const;