mesh-gatt: Fix use_after_free
authorGopal Tiwari <gtiwari@redhat.com>
Tue, 31 May 2022 07:41:17 +0000 (13:11 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
Following scenario happens when prov is false and we have double free as
mentioned in the below

bluez-5.64/tools/mesh-gatt/prov-db.c:847: freed_arg: "g_free" frees
"in_str".

bluez-5.64/tools/mesh-gatt/prov-db.c:867: double_free: Calling "g_free"
frees pointer "in_str" which has already been freed.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/mesh-gatt/prov-db.c

index 2fb08f7..a5b6997 100644 (file)
@@ -859,7 +859,8 @@ bool prov_db_local_set_iv_index(uint32_t iv_index, bool update, bool prov)
 
                set_local_iv_index(jmain, iv_index, update);
                prov_file_write(jmain, false);
-       }
+       } else
+               return true;
 
        res = true;
 done: