From 965bb0693c0df04e6dbd57a8b471944367cf6c4e Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 11 May 2021 09:04:19 +0200 Subject: 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 --- g10/pkglue.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'g10/pkglue.c') 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; } -- cgit v1.2.3