bthost: Fix sending uninitilized data
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 11 Nov 2020 22:42:36 +0000 (14:42 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:33 +0000 (19:08 +0530)
Syscall param writev(vector[...]) points to uninitialised byte(s)
   at 0x4A8A497: writev (in /usr/lib64/libc-2.31.so)
   by 0x1365C1: send_packet (bthost.c:509)
   by 0x1365C1: send_packet (bthost.c:492)
   by 0x1365C1: next_cmd (bthost.c:737)
   by 0x137578: evt_cmd_complete (bthost.c:882)
   by 0x137578: process_evt (bthost.c:1343)
   by 0x137578: bthost_receive_h4 (bthost.c:2414)
   by 0x12DF49: receive_bthost.part.0 (hciemu.c:134)
   by 0x48B978E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6)
   by 0x48B9B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6)
   by 0x48B9E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6)
   by 0x14A664: mainloop_run (mainloop-glib.c:66)
   by 0x14AA41: mainloop_run_with_signal (mainloop-notify.c:188)
   by 0x149A7B: tester_run (tester.c:871)
   by 0x129C77: main (mgmt-tester.c:10219)
 Address 0x4c48c05 is 21 bytes inside a block of size 280 alloc'd
   at 0x483CAE9: calloc (vg_replace_malloc.c:760)
   by 0x136487: queue_command (bthost.c:472)
   by 0x136487: send_command (bthost.c:715)
   by 0x13948A: bthost_set_ext_adv_enable (bthost.c:2581)
   by 0x12CEBF: trigger_device_found (mgmt-tester.c:8513)
   by 0x148C9A: wait_callback (tester.c:749)
   by 0x48BA330: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6)
   by 0x48B978E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.6)
   by 0x48B9B17: ??? (in /usr/lib64/libglib-2.0.so.0.6400.6)
   by 0x48B9E32: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.6)
   by 0x14A664: mainloop_run (mainloop-glib.c:66)
   by 0x14AA41: mainloop_run_with_signal (mainloop-notify.c:188)
   by 0x149A7B: tester_run (tester.c:871)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
emulator/bthost.c

index 715900c..c494fcb 100755 (executable)
@@ -2576,6 +2576,7 @@ void bthost_set_ext_adv_enable(struct bthost *bthost, uint8_t enable)
        send_command(bthost, BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
                                                        &cp, sizeof(cp));
 
+       memset(&cp_enable, 0, sizeof(cp_enable));
        cp_enable.enable = enable;
        send_command(bthost, BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE, &cp_enable,
                                        sizeof(cp_enable));