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 30393ee236)
(cherry picked from commit cc6c9468fc)
(cherry picked from commit e4750efb23)
This commit is contained in:
Beniamino Galvani 2017-05-23 16:34:37 +02:00
parent 9cf9e21247
commit d4cbae9aa0

View file

@ -2923,11 +2923,12 @@ nmc_util_is_domain (const char *domain)
} }
static gboolean 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; gs_free char *val_strip = NULL;
char *val_strip; gs_strfreev char **strv = NULL;
const char *delimiters = " \t,"; const char *delimiters = " \t,";
char **iter;
long int val_int; long int val_int;
GBytes *bytes; GBytes *bytes;
GByteArray *array = NULL; GByteArray *array = NULL;
@ -2939,10 +2940,8 @@ nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *v
/* First try hex string in the format of AAbbCCDd */ /* First try hex string in the format of AAbbCCDd */
bytes = nm_utils_hexstr2bin (val_strip); bytes = nm_utils_hexstr2bin (val_strip);
if (bytes) { if (bytes)
array = g_bytes_unref_to_array (bytes);
goto done; goto done;
}
/* Otherwise, consider the following format: AA b 0xCc D */ /* Otherwise, consider the following format: AA b 0xCc D */
strv = nmc_strsplit_set (val_strip, delimiters, 0); strv = nmc_strsplit_set (val_strip, delimiters, 0);
@ -2950,19 +2949,21 @@ nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *v
for (iter = strv; iter && *iter; iter++) { for (iter = strv; iter && *iter; iter++) {
if (!nmc_string_to_int_base (g_strstrip (*iter), 16, TRUE, 0, 255, &val_int)) { 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_set_error (error, 1, 0, _("'%s' is not a valid hex character"), *iter);
g_byte_array_free (array, TRUE);
success = FALSE; success = FALSE;
goto done; goto done;
} }
g_byte_array_append (array, (const guint8 *) &val_int, 1); g_byte_array_append (array, (const guint8 *) &val_int, 1);
} }
bytes = g_byte_array_free_to_bytes (array);
done: done:
if (success) 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; return success;
} }
@ -3617,7 +3618,7 @@ DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_autheap, _802_1X_val
static gboolean static gboolean
nmc_property_802_1X_set_password_raw (NMSetting *setting, const char *prop, const char *val, GError **error) 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 * static const char *