Skip to content

Commit

Permalink
Fix an undefined return value in ksba_cert_get_digest_algo.
Browse files Browse the repository at this point in the history
* 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 3f74c2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/cert.c
Expand Up @@ -464,7 +464,10 @@ ksba_cert_get_digest_algo (ksba_cert_t cert)


n = _ksba_asn_find_node (cert->root, "Certificate.signatureAlgorithm"); n = _ksba_asn_find_node (cert->root, "Certificate.signatureAlgorithm");
if (!n || n->off == -1) if (!n || n->off == -1)
err = gpg_error (GPG_ERR_UNKNOWN_ALGORITHM); {
algo = NULL;
err = gpg_error (GPG_ERR_UNKNOWN_ALGORITHM);
}
else else
err = _ksba_parse_algorithm_identifier (cert->image + n->off, err = _ksba_parse_algorithm_identifier (cert->image + n->off,
n->nhdr + n->len, &nread, &algo); n->nhdr + n->len, &nread, &algo);
Expand Down
3 changes: 2 additions & 1 deletion tests/cert-basic.c
Expand Up @@ -448,7 +448,8 @@ one_file (const char *fname)


oid = ksba_cert_get_digest_algo (cert); oid = ksba_cert_get_digest_algo (cert);
s = get_oid_desc (oid); 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. */ /* Under Windows the _ksba_keyinfo_from_sexp are not exported. */
#ifndef __WIN32 #ifndef __WIN32
Expand Down

0 comments on commit 3f74c2c

Please sign in to comment.