uuid: Fix crashing if a NULL string is passed to bt_string_to_uuid
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 10 Feb 2022 00:03:45 +0000 (16:03 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:53 +0000 (14:55 +0530)
bt_string_to_uuid shall chack if the string is valid before attempting
to access its contents.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
lib/uuid.c

index 3d97dc8..1d2e1f7 100755 (executable)
@@ -251,6 +251,9 @@ static int bt_string_to_uuid128(bt_uuid_t *uuid, const char *string)
 
 int bt_string_to_uuid(bt_uuid_t *uuid, const char *string)
 {
+       if (!string)
+               return -EINVAL;
+
        if (is_base_uuid128(string))
                return bt_string_to_uuid16(uuid, string + 4);
        else if (is_uuid128(string))