From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: helei.sig11@bytedance.com, pizhenwei@bytedance.com, berrange@redhat.com
Subject: [PATCH] crypto/rsakey-builtin.c.inc: Clean up two error paths
Date: Fri, 1 Sep 2023 14:32:26 +0200 [thread overview]
Message-ID: <20230901123226.3656164-1-armbru@redhat.com> (raw)
When qcrypto_builtin_rsa_public_key_parse() is about to fail, but no
error has been set, it makes one up. Actually, there's just one way
to fail without setting an error. Set it there instead.
Same for qcrypto_builtin_rsa_private_key_parse().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
crypto/rsakey-builtin.c.inc | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/crypto/rsakey-builtin.c.inc b/crypto/rsakey-builtin.c.inc
index aeeacc8f9b..46cc7afe87 100644
--- a/crypto/rsakey-builtin.c.inc
+++ b/crypto/rsakey-builtin.c.inc
@@ -88,15 +88,13 @@ static QCryptoAkCipherRSAKey *qcrypto_builtin_rsa_public_key_parse(
goto error;
}
if (seq_length != 0) {
+ error_setg(errp, "Invalid RSA public key");
goto error;
}
return rsa;
error:
- if (errp && !*errp) {
- error_setg(errp, "Invalid RSA public key");
- }
qcrypto_akcipher_rsakey_free(rsa);
return NULL;
}
@@ -169,15 +167,13 @@ static QCryptoAkCipherRSAKey *qcrypto_builtin_rsa_private_key_parse(
return rsa;
}
if (seq_length != 0) {
+ error_setg(errp, "Invalid RSA private key");
goto error;
}
return rsa;
error:
- if (errp && !*errp) {
- error_setg(errp, "Invalid RSA private key");
- }
qcrypto_akcipher_rsakey_free(rsa);
return NULL;
}
--
2.41.0
next reply other threads:[~2023-09-01 12:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-01 12:32 Markus Armbruster [this message]
2023-09-08 10:07 ` [PATCH] crypto/rsakey-builtin.c.inc: Clean up two error paths Daniel P. Berrangé
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=20230901123226.3656164-1-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=helei.sig11@bytedance.com \
--cc=pizhenwei@bytedance.com \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).