Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ea72d19 authored by Ganesh Ganapathi Batta's avatar Ganesh Ganapathi Batta
Browse files

fix random crashes in bd2str caused by exceeding string array

remove all casts to avoid sign extension of bd address as this may
exceed the size of destination str buffer

Change-Id: I27dc7e61b52440c6b284b7e9931e6daa66afbf12
parent d8402708
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ int str2bd(char *str, bt_bdaddr_t *addr)
{
    int32_t i = 0;
    for (i = 0; i < 6; i++) {
       addr->address[i] = (uint8_t) strtoul(str, (char **)&str, 16);
       addr->address[i] = (uint8_t)strtoul(str, &str, 16);
       str++;
    }
    return 0;
@@ -95,10 +95,10 @@ char *bd2str(const bt_bdaddr_t *bdaddr, bdstr_t *bdstr)
{
    const uint8_t *addr = bdaddr->address;

    snprintf((char*)bdstr, sizeof(*bdstr), "%02x:%02x:%02x:%02x:%02x:%02x",
    sprintf(*bdstr, "%02x:%02x:%02x:%02x:%02x:%02x",
             addr[0], addr[1], addr[2],
             addr[3], addr[4], addr[5]);
    return (char *)bdstr;
    return *bdstr;
}

UINT32 devclass2uint(DEV_CLASS dev_class)