[gnome-control-center/gnome-3-8] network: Fix empty ignore-hosts setting



commit d2a176493d869f92204aae3f610c44904ccdde05
Author: Rui Matos <tiagomatos gmail com>
Date:   Thu Sep 12 13:18:14 2013 +0200

    network: Fix empty ignore-hosts setting
    
    If the ignore-hosts setting is set to an empty array we were using
    unintialized memory.
    
    This also now ignores zero length strings if there are any in the
    array.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707966

 panels/network/net-proxy.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/panels/network/net-proxy.c b/panels/network/net-proxy.c
index 5b53f43..a883d4c 100644
--- a/panels/network/net-proxy.c
+++ b/panels/network/net-proxy.c
@@ -263,19 +263,22 @@ get_ignore_hosts (GValue   *value,
                   GVariant *variant,
                   gpointer  user_data)
 {
-        int i;
-        gsize n = 0, avlen;
-        gchar buffer[10240];
-        gchar *p = buffer;
-        const gchar **av = g_variant_get_strv (variant, &avlen);
-
-        if (avlen > 0) {
-                n = g_strlcpy (p, av[0], sizeof buffer);
-                for (i = 1; i < avlen; i ++)
-                        n += g_snprintf (p + n, sizeof (buffer) - n, ", %s", av[i]);
-        }
+        GVariantIter iter;
+        const gchar *s;
+        gchar **av, **p;
+        gsize n;
+
+        n = g_variant_iter_init (&iter, variant);
+        p = av = g_new0 (gchar *, n + 1);
+
+        while (g_variant_iter_next (&iter, "&s", &s))
+                if (s[0] != '\0') {
+                        *p = (gchar *) s;
+                        ++p;
+                }
+
+        g_value_take_string (value, g_strjoinv (", ", av));
         g_free (av);
-        g_value_set_string (value, buffer);
 
         return TRUE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]