Skip to contentSkip to conversation

mesh: Fix crash while reading input parameters

PATCH Applied Luiz Augusto von Dentz 3 participants 3 messages Dec 8, 2017 – Dec 11, 2017 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/1 mesh: Fix crash while reading input parameters

From: Luiz Augusto von Dentz <[email protected]>

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(-)
mesh/config-client.c +4 -1
index 7aabe6ce7..3d618b6a6 100644
@@ -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));
mesh/onoff-model.c +4 -1
index 9c8869414..fc0d64617 100644
@@ -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));
Signature · 1 line
2.13.6
#1 lore raw

Hi Luiz,

Quoted 48 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

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(-)
mesh/config-client.c +4 -1
index 7aabe6ce7..3d618b6a6 100644
@@ -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;
 
mesh/config-client.c +0 -0
 	memset(parms, 0xff, sizeof(parms));
mesh/onoff-model.c +4 -1
index 9c8869414..fc0d64617 100644
@@ -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;
 
Quoted 1 line

memset(parms, 0xff, sizeof(parms));

I tested both config and onoff.

Both fixed.

Thanks,

Steve

#2 lore raw
In reply to Luiz Augusto von Dentz

Hi Luiz,

Quoted 6 lines · Luiz Augusto von Dentz

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

Applied. Thanks.

Johan