diff options
author | Thomas Haller <thaller@redhat.com> | 2014-11-30 23:28:18 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-12-03 17:44:31 +0100 |
commit | 20daaa5734382cbab501f093f1bccd3604f870d3 (patch) | |
tree | 3a12ff501a68e6b8a25ed8b587b0cec1a08c8076 | |
parent | 251d96dcc6c1014fdb5e291bd59ddc82445b6e90 (diff) | |
download | NetworkManager-th/uuid-variant3-bgo740865.tar.gz |
REJECTED -- libnm: coerce NMSettingConnection:uuid to be validth/uuid-variant3-bgo740865
Invalid UUIDs are "recreated" as variant3 UUIDs based on the
original value.
-rw-r--r-- | libnm-core/nm-setting-connection.c | 2 | ||||
-rw-r--r-- | libnm-core/tests/test-general.c | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index f478d1cf5c..6c7daf2fff 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -1095,7 +1095,7 @@ set_property (GObject *object, guint prop_id, for (u = priv->uuid; *u; u++) *u = g_ascii_tolower (*u); } else - priv->uuid = strdup (uuid); + priv->uuid = nm_utils_uuid_generate_from_string (uuid, -1, NM_UTILS_UUID_TYPE_VARIANT3, "ccbdbd56-3315-42d2-a19a-913d8123a1f1"); } break; } diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 28d52b53b3..5309a59b41 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -3015,6 +3015,7 @@ test_connection_uuid_coerce_tolower (void) const char *UUID = "969f0eb6-8151-4cf8-9dc9-60f1f258B343"; /* has uppercase here ^ */ const char *UUID_INVAL = "969f0eb6-8151-4cf8-9dc9-60f1f258B343x"; + gs_free char *uuid_inval_coerced = NULL; con = nmtst_create_minimal_connection ("test1", UUID, NM_SETTING_WIRED_SETTING_NAME, NULL); @@ -3027,11 +3028,12 @@ test_connection_uuid_coerce_tolower (void) NULL); g_assert (!nm_connection_get_uuid (con)); - /* non UUIDs should not be coerced. */ + /* invalid UUIDs should not be coerced. */ g_object_set (nm_connection_get_setting_connection (con), NM_SETTING_CONNECTION_UUID, UUID_INVAL, NULL); - g_assert_cmpstr (UUID_INVAL, ==, nm_connection_get_uuid (con)); + uuid_inval_coerced = nm_utils_uuid_generate_from_string (UUID_INVAL, -1, NM_UTILS_UUID_TYPE_VARIANT3, "ccbdbd56-3315-42d2-a19a-913d8123a1f1"); + g_assert_cmpstr (uuid_inval_coerced, ==, nm_connection_get_uuid (con)); } /******************************************************************************/ |