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

Florian Festi ffesti at redhat.com
Wed Aug 24 16:27:44 UTC 2016


Nice catch! Thank you very much for the patch! Pushed.

Florian

On 08/09/2016 04:52 PM, Stefan Berger wrote:
> 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;
>      }
> 


-- 

Red Hat GmbH, http://www.de.redhat.com/, Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Paul Argiry, Charles Cachera, Michael Cunningham,
Michael O'Neill


More information about the Rpm-maint mailing list