X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/55ae7a516126f9f064d8353bf962256b7307590a..34b491e735ad47c4805e63f3b83a659b8d10262b:/apt-pkg/contrib/hashes.cc?ds=sidebyside diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 41a0037cd..662c2bf8b 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -129,13 +129,24 @@ APT_PURE bool HashString::empty() const /*{{{*/ return (Type.empty() || Hash.empty()); } /*}}}*/ + +APT_PURE static bool IsConfigured(const char *name, const char *what) +{ + std::string option; + strprintf(option, "APT::Hashes::%s::%s", name, what); + return _config->FindB(option, false); +} + APT_PURE bool HashString::usable() const /*{{{*/ { return ( (Type != "Checksum-FileSize") && - (Type != "MD5Sum") + (Type != "MD5Sum") && + (Type != "SHA1") && + !IsConfigured(Type.c_str(), "Untrusted") ); } + /*}}}*/ std::string HashString::toStr() const /*{{{*/ { return Type + ":" + Hash; @@ -301,6 +312,8 @@ public: // Hashes::Add* - Add the contents of data or FD /*{{{*/ bool Hashes::Add(const unsigned char * const Data, unsigned long long const Size) { + if (Size == 0) + return true; bool Res = true; APT_IGNORE_DEPRECATED_PUSH if ((d->CalcHashes & MD5SUM) == MD5SUM)