[PATCH BlueZ] client/assistant: Use strnlen() instead of strlen()

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

 



Using strlen() can lead to undefined behavior.
---
 client/assistant.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/client/assistant.c b/client/assistant.c
index 5850b5827..3551aaad8 100644
--- a/client/assistant.c
+++ b/client/assistant.c
@@ -261,7 +261,7 @@ static void assistant_set_bcode_cfg(const char *input, void *user_data)
 	if (!strcasecmp(input, "a") || !strcasecmp(input, "auto")) {
 		memset(cfg->qos.bcast.bcode, 0, BCODE_LEN);
 	} else {
-		if (strlen(input) > BCODE_LEN) {
+		if (strnlen(input, BCODE_LEN + 1) > BCODE_LEN) {
 			bt_shell_printf("Input string too long %s\n", input);
 			goto fail;
 		}
-- 
2.43.0





[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