aboutsummaryrefslogtreecommitdiff
path: root/chardev
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2021-06-28 18:09:11 +0200
committerDaniel P. Berrangé <berrange@redhat.com>2021-06-29 18:30:17 +0100
commit8612df2ebef9ff1f880fe76d223a3369b9c98db2 (patch)
tree6aec4df64b07d19ab03473cc23bc48b2a32fd835 /chardev
parent0279cd9535283cf5711768ab6401b204e5697a81 (diff)
downloadqemu-8612df2ebef9ff1f880fe76d223a3369b9c98db2.zip
qemu-8612df2ebef9ff1f880fe76d223a3369b9c98db2.tar.gz
qemu-8612df2ebef9ff1f880fe76d223a3369b9c98db2.tar.bz2
chardev/socket: Use qcrypto_tls_creds_check_endpoint()
Avoid accessing QCryptoTLSCreds internals by using the qcrypto_tls_creds_check_endpoint() helper. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'chardev')
-rw-r--r--chardev/char-socket.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index daa89fe..d0fb545 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -1402,18 +1402,12 @@ static void qmp_chardev_open_socket(Chardev *chr,
return;
}
object_ref(OBJECT(s->tls_creds));
- if (is_listen) {
- if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
- error_setg(errp, "%s",
- "Expected TLS credentials for server endpoint");
- return;
- }
- } else {
- if (s->tls_creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) {
- error_setg(errp, "%s",
- "Expected TLS credentials for client endpoint");
- return;
- }
+ if (!qcrypto_tls_creds_check_endpoint(s->tls_creds,
+ is_listen
+ ? QCRYPTO_TLS_CREDS_ENDPOINT_SERVER
+ : QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT,
+ errp)) {
+ return;
}
}
s->tls_authz = g_strdup(sock->tls_authz);