mesh: Fix crash while reading input parameters
Luiz Augusto von Dentz
maintainerPATCH 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
@@ -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
@@ -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
Hi Luiz,
Quoted 48 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
read_input_parametersskips 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@@ -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
-0memset (parms,0xff ,sizeof (parms));mesh/onoff-model.c +4
-1@@ -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
Johan Hedberg
AppliedHi Luiz,
Quoted 6 lines · Luiz Augusto von Dentz
read_input_parametersskips 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