[gnome-control-center] network: Fix empty ignore-hosts setting
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Fix empty ignore-hosts setting
- Date: Fri, 13 Sep 2013 11:24:06 +0000 (UTC)
commit 0f64dd1a11eda55c6969dcc7a33239c00b1b99a8
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]