Skip to content
Permalink
Browse files

Fix an undefined return value in ksba_cert_get_digest_algo.

* src/cert.c (ksba_cert_get_digest_algo): Set ALGO in the error case.
* tests/cert-basic.c (one_file): Take care of printf which does not
handle NULL for %s
--

GnuPG-bug-id: 2343
Reported-by: Pascal Cuoq
  • Loading branch information...
dd9jn committed May 3, 2016
1 parent 6be61da commit 3f74c2cc0068d0b3584627af73c8c42ce720a826
Showing with 6 additions and 2 deletions.
  1. +4 −1 src/cert.c
  2. +2 −1 tests/cert-basic.c
@@ -464,7 +464,10 @@ ksba_cert_get_digest_algo (ksba_cert_t cert)

n = _ksba_asn_find_node (cert->root, "Certificate.signatureAlgorithm");
if (!n || n->off == -1)
err = gpg_error (GPG_ERR_UNKNOWN_ALGORITHM);
{
algo = NULL;
err = gpg_error (GPG_ERR_UNKNOWN_ALGORITHM);
}
else
err = _ksba_parse_algorithm_identifier (cert->image + n->off,
n->nhdr + n->len, &nread, &algo);
@@ -448,7 +448,8 @@ one_file (const char *fname)

oid = ksba_cert_get_digest_algo (cert);
s = get_oid_desc (oid);
printf (" hash algo.: %s%s%s%s\n", oid, s?" (":"",s?s:"",s?")":"");
printf (" hash algo.: %s%s%s%s\n",
oid?oid:"(null)", s?" (":"",s?s:"",s?")":"");

/* Under Windows the _ksba_keyinfo_from_sexp are not exported. */
#ifndef __WIN32

0 comments on commit 3f74c2c

Please sign in to comment.
You can’t perform that action at this time.