qemu-nbd: Use qcrypto_tls_creds_check_endpoint()
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>
This commit is contained in:
parent
7b3b616838
commit
0279cd9535
19
qemu-nbd.c
19
qemu-nbd.c
@ -43,6 +43,7 @@
|
|||||||
#include "io/channel-socket.h"
|
#include "io/channel-socket.h"
|
||||||
#include "io/net-listener.h"
|
#include "io/net-listener.h"
|
||||||
#include "crypto/init.h"
|
#include "crypto/init.h"
|
||||||
|
#include "crypto/tlscreds.h"
|
||||||
#include "trace/control.h"
|
#include "trace/control.h"
|
||||||
#include "qemu-version.h"
|
#include "qemu-version.h"
|
||||||
|
|
||||||
@ -422,18 +423,12 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, bool list,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list) {
|
if (!qcrypto_tls_creds_check_endpoint(creds,
|
||||||
if (creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) {
|
list
|
||||||
error_setg(errp,
|
? QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT
|
||||||
"Expecting TLS credentials with a client endpoint");
|
: QCRYPTO_TLS_CREDS_ENDPOINT_SERVER,
|
||||||
return NULL;
|
errp)) {
|
||||||
}
|
return NULL;
|
||||||
} else {
|
|
||||||
if (creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
|
|
||||||
error_setg(errp,
|
|
||||||
"Expecting TLS credentials with a server endpoint");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
object_ref(obj);
|
object_ref(obj);
|
||||||
return creds;
|
return creds;
|
||||||
|
Loading…
Reference in New Issue
Block a user