[PATCH BlueZ 2/3] Fix g_strndup() call for EIR name

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

 



Use the actual string length (without the trailing NUL terminator) for
g_strndup(), because it allocates and inserts a trailing NUL byte.
---
 src/eir.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index ff50cf8..96aa763 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -169,8 +169,7 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len)
 
 			g_free(eir->name);
 
-			eir->name = g_strndup((char *) &eir_data[2],
-								field_len - 1);
+			eir->name = g_strndup((char *) &eir_data[2], name_len);
 			eir->name_complete = eir_data[1] == EIR_NAME_COMPLETE;
 			break;
 		}
-- 
1.7.0.4

--
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