summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2009-06-30 15:27:47 +0300
committerJohan Hedberg <johan.hedberg@nokia.com>2009-06-30 15:32:02 +0300
commit08fef64ca40b85782a0de1c1fd098934355b5e24 (patch)
treeac39387226487ea89b61bde1bcb5cfac7e939be1 /src
parentc36dc7d210de981ba8b94d567ecb60017e12b5d1 (diff)
Fix name length checks
Bluetooth friendly names do not have to be nul-terminated if they are exactly 248 characters long, however the internal representations of them in bluetoothd that get passed to e.g. D-Bus messages need to be 249 characters long to accomodate for the nul-terminator.
Diffstat (limited to 'src')
-rw-r--r--src/device.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/device.c b/src/device.c
index f4746a28..3a329d5c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -109,7 +109,7 @@ struct browse_req {
struct btd_device {
bdaddr_t bdaddr;
gchar *path;
- char name[248];
+ char name[MAX_NAME_LENGTH + 1];
struct btd_adapter *adapter;
GSList *uuids;
GSList *drivers; /* List of driver_data */
@@ -271,7 +271,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
DBusMessageIter iter;
DBusMessageIter dict;
bdaddr_t src;
- char name[248], srcaddr[18], dstaddr[18];
+ char name[MAX_NAME_LENGTH + 1], srcaddr[18], dstaddr[18];
char **uuids;
const char *ptr;
dbus_bool_t boolean;
@@ -874,14 +874,14 @@ struct btd_device *device_create(DBusConnection *conn,
void device_set_name(struct btd_device *device, const char *name)
{
DBusConnection *conn = get_dbus_connection();
- char alias[248];
+ char alias[MAX_NAME_LENGTH + 1];
char srcaddr[18], dstaddr[18];
bdaddr_t src;
- if (strncmp(name, device->name, 248) == 0)
+ if (strncmp(name, device->name, MAX_NAME_LENGTH) == 0)
return;
- strncpy(device->name, name, 248);
+ strncpy(device->name, name, MAX_NAME_LENGTH);
emit_property_changed(conn, device->path,
DEVICE_INTERFACE, "Name",