[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 30/64] qemu-nbd: Use qcrypto_tls_creds_check_endpoint()
From: |
Michael Roth |
Subject: |
[PATCH 30/64] qemu-nbd: Use qcrypto_tls_creds_check_endpoint() |
Date: |
Tue, 19 Oct 2021 09:09:10 -0500 |
From: Philippe Mathieu-Daudé <philmd@redhat.com>
Avoid accessing QCryptoTLSCreds internals by using
the qcrypto_tls_creds_check_endpoint() helper.
Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 0279cd9535283cf5711768ab6401b204e5697a81)
Signed-off-by: Michael Roth <michael.roth@amd.com>
---
qemu-nbd.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
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;
--
2.25.1
- [PATCH 01/64] multi-process: Initialize variables declared with g_auto*, (continued)
- [PATCH 01/64] multi-process: Initialize variables declared with g_auto*, Michael Roth, 2021/10/19
- [PATCH 21/64] runstate: Initialize Error * to NULL, Michael Roth, 2021/10/19
- [PATCH 22/64] vfio: Fix unregister SaveVMHandler in vfio_migration_finalize, Michael Roth, 2021/10/19
- [PATCH 23/64] vl: Fix an assert failure in error path, Michael Roth, 2021/10/19
- [PATCH 24/64] tcg/sparc: Fix temp_allocate_frame vs sparc stack bias, Michael Roth, 2021/10/19
- [PATCH 25/64] tcg: Allocate sufficient storage in temp_allocate_frame, Michael Roth, 2021/10/19
- [PATCH 26/64] hw/pci-host/q35: Ignore write of reserved PCIEXBAR LENGTH field, Michael Roth, 2021/10/19
- [PATCH 27/64] block/nvme: Fix VFIO_MAP_DMA failed: No space left on device, Michael Roth, 2021/10/19
- [PATCH 28/64] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper, Michael Roth, 2021/10/19
- [PATCH 29/64] block/nbd: Use qcrypto_tls_creds_check_endpoint(), Michael Roth, 2021/10/19
- [PATCH 30/64] qemu-nbd: Use qcrypto_tls_creds_check_endpoint(),
Michael Roth <=
- [PATCH 02/64] linux-user/aarch64: Enable hwcap for RND, BTI, and MTE, Michael Roth, 2021/10/19
- [PATCH 31/64] chardev/socket: Use qcrypto_tls_creds_check_endpoint(), Michael Roth, 2021/10/19
- [PATCH 32/64] migration/tls: Use qcrypto_tls_creds_check_endpoint(), Michael Roth, 2021/10/19
- [PATCH 33/64] ui/vnc: Use qcrypto_tls_creds_check_endpoint(), Michael Roth, 2021/10/19
- [PATCH 34/64] crypto: Make QCryptoTLSCreds* structures private, Michael Roth, 2021/10/19
- [PATCH 35/64] yank: Unregister function when using TLS migration, Michael Roth, 2021/10/19
- [PATCH 36/64] tests: acpi: prepare for changing DSDT tables, Michael Roth, 2021/10/19
- [PATCH 37/64] acpi: pc: revert back to v5.2 PCI slot enumeration, Michael Roth, 2021/10/19
- [PATCH 38/64] tests: acpi: pc: update expected DSDT blobs, Michael Roth, 2021/10/19
- [PATCH 39/64] hw/block/nvme: align with existing style, Michael Roth, 2021/10/19