[Spice-commits] 2 commits - server/main_channel.c server/reds.c server/red_tunnel_worker.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Fri Mar 23 05:11:54 PDT 2012


 server/main_channel.c      |    4 ++--
 server/red_tunnel_worker.c |    4 ++--
 server/reds.c              |   30 ++++++++++++++----------------
 3 files changed, 18 insertions(+), 20 deletions(-)

New commits:
commit 4df135c858d7dfb1aa0ae5d3cb17d786410d1544
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Mar 20 20:29:57 2012 +0100

    sasl: small refactoring, check memcheck != NULL

diff --git a/server/reds.c b/server/reds.c
index b5d185e..30e3ac0 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2480,9 +2480,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
         if (err != SASL_OK) {
             red_printf("cannot set SASL external SSF %d (%s)",
                        err, sasl_errstring(err, NULL, NULL));
-            sasl_dispose(&sasl->conn);
-            sasl->conn = NULL;
-            goto error;
+            goto error_dispose;
         }
     } else {
         sasl->wantSSF = 1;
@@ -2510,9 +2508,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
     if (err != SASL_OK) {
         red_printf("cannot set SASL security props %d (%s)",
                    err, sasl_errstring(err, NULL, NULL));
-        sasl_dispose(&sasl->conn);
-        sasl->conn = NULL;
-        goto error;
+        goto error_dispose;
     }
 
     err = sasl_listmech(sasl->conn,
@@ -2523,13 +2519,12 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
                         &mechlist,
                         NULL,
                         NULL);
-    if (err != SASL_OK) {
+    if (err != SASL_OK || mechlist == NULL) {
         red_printf("cannot list SASL mechanisms %d (%s)",
                    err, sasl_errdetail(sasl->conn));
-        sasl_dispose(&sasl->conn);
-        sasl->conn = NULL;
-        goto error;
+        goto error_dispose;
     }
+
     red_printf("Available mechanisms for client: '%s'", mechlist);
 
     sasl->mechlist = spice_strdup(mechlist);
@@ -2549,6 +2544,9 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
 
     return;
 
+error_dispose:
+    sasl_dispose(&sasl->conn);
+    sasl->conn = NULL;
 error:
     reds_link_free(link);
     return;
commit d4ba4ee690aeb72b86c5342c77a54b5a1a185975
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Mar 20 20:29:15 2012 +0100

    Use spice_strdup() to avoid crashing on NULL
    
    qemu can call spice_server_set_name(s, NULL) when the name is not
    given. Let's not crash in this case

diff --git a/server/main_channel.c b/server/main_channel.c
index a9fd24e..dbac010 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -637,10 +637,10 @@ static void main_channel_fill_mig_target(MainChannel *main_channel, RedsMigSpice
 {
     ASSERT(mig_target);
     free(main_channel->mig_target.host);
-    main_channel->mig_target.host = strdup(mig_target->host);
+    main_channel->mig_target.host = spice_strdup(mig_target->host);
     free(main_channel->mig_target.cert_subject);
     if (mig_target->cert_subject) {
-        main_channel->mig_target.cert_subject = strdup(mig_target->cert_subject);
+        main_channel->mig_target.cert_subject = spice_strdup(mig_target->cert_subject);
     }
     main_channel->mig_target.port = mig_target->port;
     main_channel->mig_target.sport = mig_target->sport;
diff --git a/server/red_tunnel_worker.c b/server/red_tunnel_worker.c
index 80e0721..45bf6e1 100644
--- a/server/red_tunnel_worker.c
+++ b/server/red_tunnel_worker.c
@@ -1077,8 +1077,8 @@ static inline TunnelService *__tunnel_worker_add_service(TunnelWorker *worker, u
     new_service->group = group;
     new_service->port = port;
 
-    new_service->name = strdup(name);
-    new_service->description = strdup(description);
+    new_service->name = spice_strdup(name);
+    new_service->description = spice_strdup(description);
 
     ring_add(&worker->services, &new_service->ring_item);
     worker->num_services++;
diff --git a/server/reds.c b/server/reds.c
index c54d30c..b5d185e 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2397,7 +2397,7 @@ static void reds_handle_auth_mechname(void *opaque)
     }
 
     free(sasl->mechlist);
-    sasl->mechlist = strdup(sasl->mechname);
+    sasl->mechlist = spice_strdup(sasl->mechname);
 
     red_printf("Validated mechname '%s'", sasl->mechname);
 
@@ -2532,7 +2532,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
     }
     red_printf("Available mechanisms for client: '%s'", mechlist);
 
-    sasl->mechlist = strdup(mechlist);
+    sasl->mechlist = spice_strdup(mechlist);
 
     mechlistlen = strlen(mechlist);
     if (!sync_write(link->stream, &mechlistlen, sizeof(uint32_t))
@@ -3829,7 +3829,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_sasl_appname(SpiceServer *s, const char
     ASSERT(reds == s);
 #if HAVE_SASL
     free(sasl_appname);
-    sasl_appname = strdup(appname);
+    sasl_appname = spice_strdup(appname);
     return 0;
 #else
     return -1;
@@ -3839,7 +3839,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_sasl_appname(SpiceServer *s, const char
 SPICE_GNUC_VISIBLE void spice_server_set_name(SpiceServer *s, const char *name)
 {
     free(spice_name);
-    spice_name = strdup(name);
+    spice_name = spice_strdup(name);
 }
 
 SPICE_GNUC_VISIBLE void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16])
@@ -4075,9 +4075,9 @@ static int reds_set_migration_dest_info(const char* dest,
     spice_migration = spice_new0(RedsMigSpice, 1);
     spice_migration->port = port;
     spice_migration->sport = secure_port;
-    spice_migration->host = strdup(dest);
+    spice_migration->host = spice_strdup(dest);
     if (cert_subject) {
-        spice_migration->cert_subject = strdup(cert_subject);
+        spice_migration->cert_subject = spice_strdup(cert_subject);
     }
 
     reds->mig_spice = spice_migration;


More information about the Spice-commits mailing list