Blame SOURCES/0030-channel-main-Make-more-clear-that-host_data-and-cert.patch

542743
From 1f2a7a079a42ac9bccc12749c5eac4fcdbd48b2e Mon Sep 17 00:00:00 2001
542743
From: Frediano Ziglio <freddy77@gmail.com>
542743
Date: Wed, 16 Sep 2020 17:12:14 +0100
542743
Subject: [PATCH 30/31] channel-main: Make more clear that host_data and
542743
 cert_subject_data are C strings
542743
542743
After commit ab42be2b00d12d0bc98c6ddea08a7f969e83b2ac ("channel-main:
542743
Copy SpiceMigrationDstInfo into spice_migrate") host_data and
542743
cert_subject_data fields in spice_migrate structure are proper
542743
terminated C strings so:
542743
- check pointer instead of related field;
542743
- you don't need to terminate again.
542743
542743
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
542743
Acked-by: Uri Lublin <uril@redhat.com>
542743
---
542743
 src/channel-main.c | 8 ++------
542743
 1 file changed, 2 insertions(+), 6 deletions(-)
542743
542743
diff --git a/src/channel-main.c b/src/channel-main.c
542743
index 5f81975..2881d59 100644
542743
--- a/src/channel-main.c
542743
+++ b/src/channel-main.c
542743
@@ -2412,18 +2412,14 @@ static gboolean migrate_connect(spice_migrate *mig)
542743
     sport = info->sport;
542743
     host = (char*)info->host_data;
542743
 
542743
-    if (info->cert_subject_size == 0 ||
542743
+    if (info->cert_subject_data == NULL ||
542743
         strlen((const char*)info->cert_subject_data) == 0) {
542743
         /* only verify hostname if no cert subject */
542743
         g_object_set(mig->session, "verify", SPICE_SESSION_VERIFY_HOSTNAME, NULL);
542743
     } else {
542743
-        gchar *subject = g_alloca(info->cert_subject_size + 1);
542743
-        strncpy(subject, (const char*)info->cert_subject_data, info->cert_subject_size);
542743
-        subject[info->cert_subject_size] = '\0';
542743
-
542743
         // session data are already copied
542743
         g_object_set(mig->session,
542743
-                     "cert-subject", subject,
542743
+                     "cert-subject", info->cert_subject_data,
542743
                      "verify", SPICE_SESSION_VERIFY_SUBJECT,
542743
                      NULL);
542743
     }
542743
-- 
542743
2.28.0
542743