summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-09-13 14:33:14 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-09-14 15:22:19 +0200
commitd5a46051cbefe237a9b855603f6cbd50e8e407f2 (patch)
tree8352775bfc518f7f8edcd66f1e5c3794f776f036
parentb755de2540ae87f25b8699a555b557c1e291fa76 (diff)
downloadapt-d5a46051cbefe237a9b855603f6cbd50e8e407f2.tar.gz
do not generate bogus hashes if hash is disabled in apt-ftparchive
-rw-r--r--ftparchive/cachedb.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc
index ce6c865f3..17df9c1f1 100644
--- a/ftparchive/cachedb.cc
+++ b/ftparchive/cachedb.cc
@@ -485,10 +485,15 @@ bool CacheDB::GetHashes(bool const GenOnly, unsigned int const DoHashes)
if (GenOnly == true)
return true;
- return HashesList.push_back(HashString("MD5Sum", bytes2hex(CurStat.MD5, sizeof(CurStat.MD5)))) &&
- HashesList.push_back(HashString("SHA1", bytes2hex(CurStat.SHA1, sizeof(CurStat.SHA1)))) &&
- HashesList.push_back(HashString("SHA256", bytes2hex(CurStat.SHA256, sizeof(CurStat.SHA256)))) &&
- HashesList.push_back(HashString("SHA512", bytes2hex(CurStat.SHA512, sizeof(CurStat.SHA512))));
+ bool ret = true;
+#define PUSH_BACK_HASH(FLAG, TYPE, VALUE) \
+ if ((CurStat.Flags & FLAG) == FLAG) \
+ ret &= HashesList.push_back(HashString(TYPE, bytes2hex(VALUE, sizeof(VALUE))));
+ PUSH_BACK_HASH(FlMD5, "MD5Sum", CurStat.MD5);
+ PUSH_BACK_HASH(FlSHA1, "SHA1", CurStat.SHA1);
+ PUSH_BACK_HASH(FlSHA256, "SHA256", CurStat.SHA256);
+ PUSH_BACK_HASH(FlSHA512, "SHA512", CurStat.SHA512);
+ return ret;
}
/*}}}*/
// CacheDB::Finish - Write back the cache structure /*{{{*/