[PATCH v2] mesh: Fix crash while reading input parameters

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

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

read_input_parameters skips the command argument thus arg[0] shall be
considerer the fist argument.
---
 mesh/config-client.c | 5 ++++-
 mesh/onoff-model.c   | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/mesh/config-client.c b/mesh/config-client.c
index 7aabe6ce7..3d618b6a6 100644
--- a/mesh/config-client.c
+++ b/mesh/config-client.c
@@ -229,10 +229,13 @@ static uint32_t read_input_parameters(int argc, char *argv[])
 {
 	uint32_t i;
 
+	if (!argc)
+		return 0;
+
 	--argc;
 	++argv;
 
-	if (!argc || argv[1][0] == '\0')
+	if (!argc || argv[0][0] == '\0')
 		return 0;
 
 	memset(parms, 0xff, sizeof(parms));
diff --git a/mesh/onoff-model.c b/mesh/onoff-model.c
index 9c8869414..fc0d64617 100644
--- a/mesh/onoff-model.c
+++ b/mesh/onoff-model.c
@@ -152,10 +152,13 @@ static uint32_t read_input_parameters(int argc, char *argv[])
 {
 	uint32_t i;
 
+	if (!argc)
+		return 0;
+
 	--argc;
 	++argv;
 
-	if (!argc || argv[1][0] == '\0')
+	if (!argc || argv[0][0] == '\0')
 		return 0;
 
 	memset(parms, 0xff, sizeof(parms));
-- 
2.13.6

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