All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alberto Mardegan <photo@mardy.it>
To: linux-integrity@vger.kernel.org
Subject: [PATCH] libimaevm: do not crash if the certificate cannot be read
Date: Tue, 20 Dec 2022 15:07:41 +0300	[thread overview]
Message-ID: <20221220120741.150456-1-a.mardegan@omp.ru> (raw)

This code path can be triggered if someone inadvertedly swaps the key
with the certificate in the evmctl command line. Our `x` variable would
be NULL, and we need to abort further processing of the certificate.

Signed-off-by: Alberto Mardegan <a.mardegan@omp.ru>
---
 src/libimaevm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/libimaevm.c b/src/libimaevm.c
index c09ed98..5b22462 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -923,6 +923,7 @@ static int read_keyid_from_cert(uint32_t *keyid_be, const char *certfile, int tr
 		ERR_print_errors_fp(stderr);
 		log_err("read keyid: %s: Error reading x509 certificate\n",
 			certfile);
+		return -1;
 	}
 
 	if (!(skid = x509_get_skid(x, &skid_len))) {
-- 
2.34.1


             reply	other threads:[~2022-12-20 12:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-20 12:07 Alberto Mardegan [this message]
2023-01-02 14:10 ` [PATCH] libimaevm: do not crash if the certificate cannot be read Mimi Zohar
2023-01-09  7:52   ` Alberto Mardegan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221220120741.150456-1-a.mardegan@omp.ru \
    --to=photo@mardy.it \
    --cc=linux-integrity@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.