diff options
| author | yujun <yujun@kylinos.cn> | 2026-06-29 19:10:26 +0800 |
|---|---|---|
| committer | Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> | 2026-07-07 17:10:24 +0200 |
| commit | d517d26da4b83404216a3464d8b2dff58fc8d07e (patch) | |
| tree | 6ca405d2b99301710c4a84be8924b89094578794 /crypto | |
| parent | 4c883aee49c9d806cf1bc3385b0c995acdca586b (diff) | |
| download | qemu-d517d26da4b83404216a3464d8b2dff58fc8d07e.tar.gz qemu-d517d26da4b83404216a3464d8b2dff58fc8d07e.zip | |
crypto/x509-utils: fix gnutls error code in crt_init failure path
qcrypto_get_x509_cert_fingerprint() reports gnutls_strerror(ret) when
gnutls_x509_crt_init() fails, but ret is still the initial value -1.
Store the gnutls return code before formatting the error, matching
other gnutls call sites in the tree.
Fixes: 2183ab6251 ("crypto/x509-utils: Check for error from gnutls_x509_crt_init()")
Signed-off-by: yujun <yujun@kylinos.cn>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20260629111026.281185-1-yujun@kylinos.cn>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/x509-utils.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/crypto/x509-utils.c b/crypto/x509-utils.c index 39bb6d4d8c..1843488bca 100644 --- a/crypto/x509-utils.c +++ b/crypto/x509-utils.c @@ -46,7 +46,8 @@ int qcrypto_get_x509_cert_fingerprint(uint8_t *cert, size_t size, return -1; } - if (gnutls_x509_crt_init(&crt) < 0) { + ret = gnutls_x509_crt_init(&crt); + if (ret < 0) { error_setg(errp, "Unable to initialize certificate: %s", gnutls_strerror(ret)); return -1; |
