profiles/network: Fix crash in network_property_get_uuid

Crash was due to invalid use of libdbus API.

Invalid read of size 1
   at 0x4A092F2: strlen (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x36A9A29DF3: ??? (in /usr/lib64/libdbus-1.so.3.7.12)
   by 0x36A9A17CC4: ??? (in /usr/lib64/libdbus-1.so.3.7.12)
   by 0x36A9A19EAD: dbus_message_iter_append_basic (in /usr/lib64/libdbus-1.so.3.7.12)
   by 0x42B9B6: network_property_get_uuid (connection.c:453)
   by 0x4847EE: append_property.isra.1 (object.c:510)
   by 0x4849EF: process_properties_from_interface (object.c:1688)
   by 0x484D23: process_changes (object.c:1719)
   by 0x36A7E492A5: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x36A7E49627: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x36A7E49A39: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x40AF95: main (main.c:661)
 Address 0x3631313130303030 is not stack'd, malloc'd or (recently) free'd
This commit is contained in:
Szymon Janc 2015-04-09 14:14:18 +02:00
parent 546ec13c0d
commit a8b1be8f82

View File

@ -440,6 +440,7 @@ static gboolean network_property_get_uuid(const GDBusPropertyTable *property,
struct network_peer *peer = data;
struct network_conn *nc;
char uuid_str[MAX_LEN_UUID_STR];
const char *uuid = uuid_str;
bt_uuid_t uuid16, uuid128;
nc = find_connection_by_state(peer->connections, CONNECTED);
@ -450,7 +451,7 @@ static gboolean network_property_get_uuid(const GDBusPropertyTable *property,
bt_uuid_to_uuid128(&uuid16, &uuid128);
bt_uuid_to_string(&uuid128, uuid_str, MAX_LEN_UUID_STR);
dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &uuid_str);
dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &uuid);
return TRUE;
}