summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-05-23 16:34:37 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2017-05-23 16:34:37 +0200
commite4750efb2370145b9da44c1a03b59b537e207b1a (patch)
tree92ec94f12b1746e077510e348d4c84fa254ccac4
parentfaba5b7078a396e7d3394904f1c9a96d2d0fa86e (diff)
downloadNetworkManager-e4750efb2370145b9da44c1a03b59b537e207b1a.tar.gz
clients: fix setter for 802-1x.password-raw
The property is a GBytes, not a GByteArray. https://bugzilla.gnome.org/show_bug.cgi?id=782836 (cherry picked from commit 30393ee2360e8678188cc47d794f2199d50e82ba) (cherry picked from commit cc6c9468fc01d69505141ee8956766079dbed903)
-rw-r--r--clients/cli/settings.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index ee167d2c6a..f3284735ed 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -2997,11 +2997,12 @@ nmc_util_is_domain (const char *domain)
}
static gboolean
-nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *val, GError **error)
+nmc_property_set_bytes (NMSetting *setting, const char *prop, const char *val, GError **error)
{
- char **strv = NULL, **iter;
- char *val_strip;
+ gs_free char *val_strip = NULL;
+ gs_strfreev char **strv = NULL;
const char *delimiters = " \t,";
+ char **iter;
long int val_int;
GBytes *bytes;
GByteArray *array = NULL;
@@ -3013,10 +3014,8 @@ nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *v
/* First try hex string in the format of AAbbCCDd */
bytes = nm_utils_hexstr2bin (val_strip);
- if (bytes) {
- array = g_bytes_unref_to_array (bytes);
+ if (bytes)
goto done;
- }
/* Otherwise, consider the following format: AA b 0xCc D */
strv = nmc_strsplit_set (val_strip, delimiters, 0);
@@ -3024,19 +3023,21 @@ nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *v
for (iter = strv; iter && *iter; iter++) {
if (!nmc_string_to_int_base (g_strstrip (*iter), 16, TRUE, 0, 255, &val_int)) {
g_set_error (error, 1, 0, _("'%s' is not a valid hex character"), *iter);
+ g_byte_array_free (array, TRUE);
success = FALSE;
goto done;
}
g_byte_array_append (array, (const guint8 *) &val_int, 1);
}
+ bytes = g_byte_array_free_to_bytes (array);
done:
if (success)
- g_object_set (setting, prop, array, NULL);
+ g_object_set (setting, prop, bytes, NULL);
+
+ if (bytes)
+ g_bytes_unref (bytes);
- g_strfreev (strv);
- if (array)
- g_byte_array_free (array, TRUE);
return success;
}
@@ -3715,7 +3716,7 @@ DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_autheap, _802_1X_val
static gboolean
nmc_property_802_1X_set_password_raw (NMSetting *setting, const char *prop, const char *val, GError **error)
{
- return nmc_property_set_byte_array (setting, prop, val, error);
+ return nmc_property_set_bytes (setting, prop, val, error);
}
static const char *