bt: replace fragile snprintf use and unwarranted strncpy
commite5fda03839e3c61b01d6c60de5625501d01c69d0
authorJim Meyering <meyering@redhat.com>
Thu, 4 Oct 2012 11:09:55 +0000 (4 13:09 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 5 Oct 2012 12:58:37 +0000 (5 07:58 -0500)
treec5087ac23b37454f1d35a65074178cf5208ac157
parent5847d9e1399d3497be8eeca6f3a20a18a40b114b
bt: replace fragile snprintf use and unwarranted strncpy

In bt_hci_name_req a failed snprintf could return len larger than
sizeof(params.name), which means the following memset call would
have a "length" value of (size_t)-1, -2, etc...  Sounds scary.
But currently, one can deduce that there is no problem:
strlen(slave->lmp_name) is guaranteed to be smaller than
CHANGE_LOCAL_NAME_CP_SIZE, which is the same as sizeof(params.name),
so this cannot happen.  Regardless, there is no justification for
using snprintf+memset.  Use pstrcpy instead.

Also, in bt_hci_event_complete_read_local_name, use pstrcpy in place
of unwarranted strncpy.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/bt-hci.c