[Rpm-maint] [PATCH] rpmsign: Use default hash algo if RPMTAG_FILEDIGESTALGO missing

Stefan Berger stefanb at linux.vnet.ibm.com
Tue Aug 9 14:52:15 UTC 2016


Use the default hash algorithm md5 on RPMs that do not contain the
RPMTAG_FILEDIGESTALGO. This may be the case if the default hash
algorithm used on files is md5 and thus no RPMTAG_FILEDIGESTALGO is
being written (see build/files.c:genCpioListAndHeader()).

Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
---
 lib/rpmsignfiles.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/rpmsignfiles.c b/lib/rpmsignfiles.c
index 3cd2b1a..87e4e42 100644
--- a/lib/rpmsignfiles.c
+++ b/lib/rpmsignfiles.c
@@ -133,10 +133,9 @@ rpmRC rpmSignFiles(Header h, const char *key, char *keypass)
 
     algo = headerGetNumber(h, RPMTAG_FILEDIGESTALGO);
     if (!algo) {
-	rpmlog(RPMLOG_ERR, _("missing RPMTAG_FILEDIGESTALGO\n"));
-	return RPMRC_FAIL;
-    }
-    if (algo < 0 || algo >= ARRAY_SIZE(hash_algo_name)) {
+        /* use default algorithm */
+        algo = PGPHASHALGO_MD5;
+    } else if (algo < 0 || algo >= ARRAY_SIZE(hash_algo_name)) {
 	rpmlog(RPMLOG_ERR, _("File digest algorithm id is invalid"));
 	return RPMRC_FAIL;
     }
-- 
2.5.5



More information about the Rpm-maint mailing list