From 965bb0693c0df04e6dbd57a8b471944367cf6c4e Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 11 May 2021 09:04:19 +0200 Subject: [PATCH] A few minor code cleanups and typo fixes. * agent/command-ssh.c (ssh_handler_request_identities): Remove double check of ERR. * g10/getkey.c (get_pubkey_byname): Remove double use of break. * g10/pkglue.c (pk_encrypt): Handle possible NULL-ptr access due to failed malloc. Signed-off-by: Werner Koch --- README | 2 +- agent/command-ssh.c | 2 +- doc/DETAILS | 1 + g10/getkey.c | 2 -- g10/pkglue.c | 6 ++++++ scd/app-common.h | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README b/README index d21089c16..affd92ff2 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ The GNU Privacy Guard 2 ========================= - Version 2.3 (devel) + Version 2.3 Copyright 1997-2019 Werner Koch Copyright 1998-2021 Free Software Foundation, Inc. diff --git a/agent/command-ssh.c b/agent/command-ssh.c index 73f98e9cd..d5720cc1d 100644 --- a/agent/command-ssh.c +++ b/agent/command-ssh.c @@ -2518,7 +2518,7 @@ ssh_handler_request_identities (ctrl_t ctrl, xfree (cardsn); if (err) { - if (err && opt.verbose) + if (opt.verbose) gcry_log_debugsxp ("pubkey", key_public); if (gpg_err_code (err) == GPG_ERR_UNKNOWN_CURVE || gpg_err_code (err) == GPG_ERR_INV_CURVE) diff --git a/doc/DETAILS b/doc/DETAILS index 3f136e18d..bbe2ad5d5 100644 --- a/doc/DETAILS +++ b/doc/DETAILS @@ -1666,6 +1666,7 @@ Description of some debug flags: - RFC-3447 :: PKCS #1: RSA Cryptography Specifications Version 2.1 - RFC-4880 :: OpenPGP - RFC-5280 :: X.509 PKI Certificate and CRL Profile + - RFC-5652 :: CMS (STD0070) - RFC-6818 :: Updates to the X.509 PKI Certificate and CRL Profile - RFC-8398 :: Internationalized Email Addresses in X.509 Certificates. - RFC-8399 :: Internationalization Updates to RFC 5280 diff --git a/g10/getkey.c b/g10/getkey.c index 9c5a00555..c0f8b7c54 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -1164,7 +1164,6 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode, { mechanism_string = ""; rc = GPG_ERR_NO_PUBKEY; - break; } else { @@ -1180,7 +1179,6 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode, { mechanism_string = ""; rc = GPG_ERR_NO_PUBKEY; - break; } else { diff --git a/g10/pkglue.c b/g10/pkglue.c index cab007f01..1e0191e12 100644 --- a/g10/pkglue.c +++ b/g10/pkglue.c @@ -424,6 +424,11 @@ pk_encrypt (pubkey_algo_t algo, gcry_mpi_t *resarr, gcry_mpi_t data, /* Get the shared point and the ephemeral public key. */ shared = get_data_from_sexp (s_ciph, "s", &nshared); + if (!shared) + { + rc = gpg_error_from_syserror (); + goto leave; + } rc = sexp_extract_param_sos (s_ciph, "e", &public); gcry_sexp_release (s_ciph); s_ciph = NULL; @@ -464,6 +469,7 @@ pk_encrypt (pubkey_algo_t algo, gcry_mpi_t *resarr, gcry_mpi_t data, resarr[1] = get_mpi_from_sexp (s_ciph, "b", GCRYMPI_FMT_USG); } + leave: gcry_sexp_release (s_ciph); return rc; } diff --git a/scd/app-common.h b/scd/app-common.h index f194828a9..dffe1200d 100644 --- a/scd/app-common.h +++ b/scd/app-common.h @@ -45,7 +45,7 @@ /* Flags used by the app_write_learn_status. */ #define APP_LEARN_FLAG_KEYPAIRINFO 1 /* Return only keypair infos. */ #define APP_LEARN_FLAG_MULTI 2 /* Return info for all apps. */ -#define APP_LEARN_FLAG_REREAD 4 /* Re-read ifnos from the token. */ +#define APP_LEARN_FLAG_REREAD 4 /* Re-read infos from the token. */ /* List of supported card types. Generic is the usual ISO7817-4