Make rpmVerifyFile() honor rpmfi digest algorithm

This commit is contained in:
Panu Matilainen 2008-05-29 20:41:21 +03:00
parent a1e49ce26b
commit 7b696eb1a9
1 changed files with 16 additions and 10 deletions

View File

@ -92,18 +92,24 @@ int rpmVerifyFile(const rpmts ts, const rpmfi fi,
if (flags & RPMVERIFY_MD5) { if (flags & RPMVERIFY_MD5) {
unsigned char md5sum[16]; const unsigned char *digest;
rpm_off_t fsize; pgpHashAlgo algo;
size_t diglen;
/* XXX If --nomd5, then prelinked library sizes are not corrected. */ /* XXX If --nomd5, then prelinked library sizes are not corrected. */
rc = rpmDoDigest(PGPHASHALGO_MD5, fn, 0, md5sum, &fsize); if ((digest = rpmfiDigest(fi, &algo, &diglen))) {
sb.st_size = fsize; unsigned char fdigest[diglen];
if (rc) rpm_off_t fsize;
*res |= (RPMVERIFY_READFAIL|RPMVERIFY_MD5);
else { rc = rpmDoDigest(algo, fn, 0, fdigest, &fsize);
const unsigned char * MD5 = rpmfiMD5(fi); sb.st_size = fsize;
if (MD5 == NULL || memcmp(md5sum, MD5, sizeof(md5sum))) if (rc) {
*res |= (RPMVERIFY_READFAIL|RPMVERIFY_MD5);
} else if (memcmp(fdigest, digest, diglen)) {
*res |= RPMVERIFY_MD5; *res |= RPMVERIFY_MD5;
}
} else {
*res |= RPMVERIFY_MD5;
} }
} }