122 lines
4.0 KiB
Diff
122 lines
4.0 KiB
Diff
From c10c09d54b7e38dae1c73be0c5b3c7e01ac57315 Mon Sep 17 00:00:00 2001
|
|
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
Date: Tue, 23 May 2017 15:56:27 +0200
|
|
Subject: [PATCH 1/2] 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)
|
|
---
|
|
clients/cli/settings.c | 23 ++++++++++++-----------
|
|
1 file changed, 12 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
|
|
index 87b1f50..3bcd09c 100644
|
|
--- a/clients/cli/settings.c
|
|
+++ b/clients/cli/settings.c
|
|
@@ -1643,11 +1643,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;
|
|
@@ -1659,10 +1660,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);
|
|
@@ -1670,19 +1669,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;
|
|
}
|
|
|
|
@@ -2186,7 +2187,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 *
|
|
--
|
|
2.9.3
|
|
|
|
From 3ad0b8645e890523da23f550dc6db75c40da2718 Mon Sep 17 00:00:00 2001
|
|
From: Thomas Haller <thaller@redhat.com>
|
|
Date: Tue, 23 May 2017 16:01:54 +0200
|
|
Subject: [PATCH 2/2] clients: fix appending integer to result in
|
|
nmc_property_set_bytes()
|
|
|
|
(cherry picked from commit d76c190dc72df042733cca13849e18bcc13eed65)
|
|
(cherry picked from commit 06d3c95e4fc70561b12be80e5982487443d914ec)
|
|
---
|
|
clients/cli/settings.c | 5 ++++-
|
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
|
|
index 3bcd09c..e0f045a 100644
|
|
--- a/clients/cli/settings.c
|
|
+++ b/clients/cli/settings.c
|
|
@@ -1667,13 +1667,16 @@ nmc_property_set_bytes (NMSetting *setting, const char *prop, const char *val, G
|
|
strv = nmc_strsplit_set (val_strip, delimiters, 0);
|
|
array = g_byte_array_sized_new (g_strv_length (strv));
|
|
for (iter = strv; iter && *iter; iter++) {
|
|
+ guint8 v8;
|
|
+
|
|
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);
|
|
+ v8 = val_int;
|
|
+ g_byte_array_append (array, &v8, 1);
|
|
}
|
|
bytes = g_byte_array_free_to_bytes (array);
|
|
|
|
--
|
|
2.9.3
|
|
|