[PATCH BlueZ v2 5/5] Fix magic numbers for local/remote name length

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/storage.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/storage.c b/src/storage.c
index 00dc483..c64842c 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -237,8 +237,8 @@ int read_local_name(bdaddr_t *bdaddr, char *name)
 		return -ENOENT;
 
 	len = strlen(str);
-	if (len > 248)
-		str[248] = '\0';
+	if (len > HCI_MAX_NAME_LENGTH)
+		str[HCI_MAX_NAME_LENGTH] = '\0';
 	strcpy(name, str);
 
 	free(str);
@@ -319,11 +319,11 @@ int read_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t *class)
 
 int write_device_name(bdaddr_t *local, bdaddr_t *peer, char *name)
 {
-	char filename[PATH_MAX + 1], addr[18], str[249];
+	char filename[PATH_MAX + 1], addr[18], str[HCI_MAX_NAME_LENGTH + 1];
 	int i;
 
 	memset(str, 0, sizeof(str));
-	for (i = 0; i < 248 && name[i]; i++)
+	for (i = 0; i < HCI_MAX_NAME_LENGTH && name[i]; i++)
 		if ((unsigned char) name[i] < 32 || name[i] == 127)
 			str[i] = '.';
 		else
@@ -349,8 +349,8 @@ int read_device_name(const char *src, const char *dst, char *name)
 		return -ENOENT;
 
 	len = strlen(str);
-	if (len > 248)
-		str[248] = '\0';
+	if (len > HCI_MAX_NAME_LENGTH)
+		str[HCI_MAX_NAME_LENGTH] = '\0';
 	strcpy(name, str);
 
 	free(str);
-- 
1.7.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux