tools/mesh-cfg-client:
authorInga Stotland <inga.stotland@intel.com>
Fri, 12 Feb 2021 21:42:44 +0000 (13:42 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:34 +0000 (19:08 +0530)
Make sure that the values of Device UUID supplied in
CreateNetwork and AddRemoteNode methods are compliant with
RFC 4122.
Also, use a compliant value for Mesh UUID.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/mesh-cfgclient.c
tools/mesh/mesh-db.c

index f9c1c6d..99c3f9e 100644 (file)
@@ -733,7 +733,7 @@ static void create_net_setup(struct l_dbus_message *msg, void *user_data)
        struct l_dbus_message_builder *builder;
 
        /* Generate random UUID */
-       l_getrandom(app.uuid, sizeof(app.uuid));
+       l_uuid_v4(app.uuid);
 
        builder = l_dbus_message_builder_new(msg);
 
@@ -901,7 +901,7 @@ static void cmd_import_node(int argc, char *argv[])
 
        /* Device UUID */
        req->data1 = l_util_from_hexstring(argv[1], &sz);
-       if (!req->data1 || sz != 16) {
+       if (!req->data1 || sz != 16 || !l_uuid_is_valid(req->data1)) {
                l_error("Failed to generate UUID array from %s", argv[1]);
                goto fail;
        }
@@ -1300,7 +1300,7 @@ static void add_node_setup(struct l_dbus_message *msg, void *user_data)
        struct l_dbus_message_builder *builder;
 
        uuid = l_util_from_hexstring(str, &sz);
-       if (!uuid || sz != 16) {
+       if (!uuid || sz != 16 || !l_uuid_is_valid(uuid)) {
                l_error("Failed to generate UUID array from %s", str);
                return;
        }
index 0892925..147fb25 100644 (file)
@@ -1409,7 +1409,7 @@ bool mesh_db_create(const char *fname, const uint8_t token[8],
        if (!add_u8_8(jcfg, "token", token))
                goto fail;
 
-       l_getrandom(uuid, 16);
+       l_uuid_v4(uuid);
 
        if (!add_u8_16(jcfg, "uuid", uuid))
                goto fail;