All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mesh: Fix crash while reading input parameters
@ 2017-12-08 17:12 Luiz Augusto von Dentz
  2017-12-10 10:58 ` Steve Brown
  2017-12-11  9:20 ` Johan Hedberg
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2017-12-08 17:12 UTC (permalink / raw)
  To: linux-bluetooth

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

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mesh: Fix crash while reading input parameters
  2017-12-08 17:12 [PATCH v2] mesh: Fix crash while reading input parameters Luiz Augusto von Dentz
@ 2017-12-10 10:58 ` Steve Brown
  2017-12-11  9:20 ` Johan Hedberg
  1 sibling, 0 replies; 3+ messages in thread
From: Steve Brown @ 2017-12-10 10:58 UTC (permalink / raw)
  To: Luiz Augusto von Dentz, linux-bluetooth

Hi Luiz,

On Fri, 2017-12-08 at 15:12 -0200, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> 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));

I tested both config and onoff.

Both fixed.

Thanks,

Steve


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mesh: Fix crash while reading input parameters
  2017-12-08 17:12 [PATCH v2] mesh: Fix crash while reading input parameters Luiz Augusto von Dentz
  2017-12-10 10:58 ` Steve Brown
@ 2017-12-11  9:20 ` Johan Hedberg
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hedberg @ 2017-12-11  9:20 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Fri, Dec 08, 2017, Luiz Augusto von Dentz wrote:
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-12-11  9:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-08 17:12 [PATCH v2] mesh: Fix crash while reading input parameters Luiz Augusto von Dentz
2017-12-10 10:58 ` Steve Brown
2017-12-11  9:20 ` Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.