From 0279cd9535283cf5711768ab6401b204e5697a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Jun 2021 18:09:10 +0200 Subject: qemu-nbd: Use qcrypto_tls_creds_check_endpoint() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid accessing QCryptoTLSCreds internals by using the qcrypto_tls_creds_check_endpoint() helper. Tested-by: Akihiko Odaki Reviewed-by: Eric Blake Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Daniel P. Berrangé --- qemu-nbd.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'qemu-nbd.c') diff --git a/qemu-nbd.c b/qemu-nbd.c index 93ef4e288f..26ffbf15af 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -43,6 +43,7 @@ #include "io/channel-socket.h" #include "io/net-listener.h" #include "crypto/init.h" +#include "crypto/tlscreds.h" #include "trace/control.h" #include "qemu-version.h" @@ -422,18 +423,12 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, bool list, return NULL; } - if (list) { - if (creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) { - error_setg(errp, - "Expecting TLS credentials with a client endpoint"); - return NULL; - } - } else { - if (creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { - error_setg(errp, - "Expecting TLS credentials with a server endpoint"); - return NULL; - } + if (!qcrypto_tls_creds_check_endpoint(creds, + list + ? QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT + : QCRYPTO_TLS_CREDS_ENDPOINT_SERVER, + errp)) { + return NULL; } object_ref(obj); return creds; -- cgit v1.2.3