@samitouri / QOSamiQemu / commits / 4952681a5f

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> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

yujun committed Jun 29, 2026 at 19:10 UTC 4952681a5fdc29dc74396756ab85f90ee15ea9bc
1 file changed +2 -1
crypto/x509-utils.c
+2 -1
@@ -46,7 +46,8 @@ int qcrypto_get_x509_cert_fingerprint(uint8_t *cert, size_t size,
46 return -1;
47 }
48
49 - if (gnutls_x509_crt_init(&crt) < 0) {
49 + ret = gnutls_x509_crt_init(&crt);
50 + if (ret < 0) {
51 error_setg(errp, "Unable to initialize certificate: %s",
52 gnutls_strerror(ret));
53 return -1;