summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <freddy77@gmail.com>2020-09-16 17:12:14 +0100
committerFrediano Ziglio <freddy77@gmail.com>2020-09-16 17:40:46 +0100
commit1f2a7a079a42ac9bccc12749c5eac4fcdbd48b2e (patch)
treecc3c5e86ce8452c891d761d59884660ea09895aa
parentab42be2b00d12d0bc98c6ddea08a7f969e83b2ac (diff)
channel-main: Make more clear that host_data and cert_subject_data are C strings
After commit ab42be2b00d12d0bc98c6ddea08a7f969e83b2ac ("channel-main: Copy SpiceMigrationDstInfo into spice_migrate") host_data and cert_subject_data fields in spice_migrate structure are proper terminated C strings so: - check pointer instead of related field; - you don't need to terminate again. Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Acked-by: Uri Lublin <uril@redhat.com>
-rw-r--r--src/channel-main.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/channel-main.c b/src/channel-main.c
index 5f81975..2881d59 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -2412,18 +2412,14 @@ static gboolean migrate_connect(spice_migrate *mig)
sport = info->sport;
host = (char*)info->host_data;
- if (info->cert_subject_size == 0 ||
+ if (info->cert_subject_data == NULL ||
strlen((const char*)info->cert_subject_data) == 0) {
/* only verify hostname if no cert subject */
g_object_set(mig->session, "verify", SPICE_SESSION_VERIFY_HOSTNAME, NULL);
} else {
- gchar *subject = g_alloca(info->cert_subject_size + 1);
- strncpy(subject, (const char*)info->cert_subject_data, info->cert_subject_size);
- subject[info->cert_subject_size] = '\0';
-
// session data are already copied
g_object_set(mig->session,
- "cert-subject", subject,
+ "cert-subject", info->cert_subject_data,
"verify", SPICE_SESSION_VERIFY_SUBJECT,
NULL);
}