[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 3/7] qemu-nbd: Use qcrypto_tls_creds_check_endpoint()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v6 3/7] qemu-nbd: Use qcrypto_tls_creds_check_endpoint() |
Date: |
Mon, 28 Jun 2021 18:09:10 +0200 |
Avoid accessing QCryptoTLSCreds internals by using
the qcrypto_tls_creds_check_endpoint() helper.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
qemu-nbd.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 93ef4e288fd..26ffbf15af0 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;
--
2.31.1
- [PATCH v6 0/7] crypto: Make QCryptoTLSCreds* structures private, Philippe Mathieu-Daudé, 2021/06/28
- [PATCH v6 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper, Philippe Mathieu-Daudé, 2021/06/28
- [PATCH v6 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint(), Philippe Mathieu-Daudé, 2021/06/28
- [PATCH v6 4/7] chardev/socket: Use qcrypto_tls_creds_check_endpoint(), Philippe Mathieu-Daudé, 2021/06/28
- [PATCH v6 5/7] migration/tls: Use qcrypto_tls_creds_check_endpoint(), Philippe Mathieu-Daudé, 2021/06/28
- [PATCH v6 6/7] ui/vnc: Use qcrypto_tls_creds_check_endpoint(), Philippe Mathieu-Daudé, 2021/06/28
- [PATCH v6 7/7] crypto: Make QCryptoTLSCreds* structures private, Philippe Mathieu-Daudé, 2021/06/28
- [PATCH v6 3/7] qemu-nbd: Use qcrypto_tls_creds_check_endpoint(),
Philippe Mathieu-Daudé <=