linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH obexd 3/4] irmc: Fix length parameter of strncpy
@ 2012-02-02 11:34 Jaganath Kanakkassery
  2012-02-02 17:29 ` Luiz Augusto von Dentz
  2012-02-09 11:03 ` Johan Hedberg
  0 siblings, 2 replies; 6+ messages in thread
From: Jaganath Kanakkassery @ 2012-02-02 11:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jaganath Kanakkassery

---
 plugins/irmc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/plugins/irmc.c b/plugins/irmc.c
index 6f28e51..8344a47 100644
--- a/plugins/irmc.c
+++ b/plugins/irmc.c
@@ -215,9 +215,9 @@ static void *irmc_connect(struct obex_session *os, int *err)
 	 * For now lets used hostname and some 'random' value
 	 */
 	gethostname(irmc->did, DID_LEN);
-	strncpy(irmc->sn, "12345", DID_LEN);
-	strncpy(irmc->manu, "obex", DID_LEN);
-	strncpy(irmc->model, "mymodel", DID_LEN);
+	strncpy(irmc->sn, "12345", sizeof(irmc->sn) - 1);
+	strncpy(irmc->manu, "obex", sizeof(irmc->manu) - 1);
+	strncpy(irmc->model, "mymodel", sizeof(irmc->model) - 1);
 
 	/* We need to know the number of contact/cal/nt entries
 	 * somewhere so why not do it now.
-- 
1.7.1


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

* Re: [PATCH obexd 3/4] irmc: Fix length parameter of strncpy
  2012-02-02 11:34 [PATCH obexd 3/4] irmc: Fix length parameter of strncpy Jaganath Kanakkassery
@ 2012-02-02 17:29 ` Luiz Augusto von Dentz
  2012-02-03 12:22   ` Jaganath
  2012-02-09 11:03 ` Johan Hedberg
  1 sibling, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-02-02 17:29 UTC (permalink / raw)
  To: Jaganath Kanakkassery; +Cc: linux-bluetooth

Hi Jaganath,

On Thu, Feb 2, 2012 at 3:34 AM, Jaganath Kanakkassery
<jaganath.k@samsung.com> wrote:
> ---
>  plugins/irmc.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/plugins/irmc.c b/plugins/irmc.c
> index 6f28e51..8344a47 100644
> --- a/plugins/irmc.c
> +++ b/plugins/irmc.c
> @@ -215,9 +215,9 @@ static void *irmc_connect(struct obex_session *os, int *err)
>         * For now lets used hostname and some 'random' value
>         */
>        gethostname(irmc->did, DID_LEN);
> -       strncpy(irmc->sn, "12345", DID_LEN);
> -       strncpy(irmc->manu, "obex", DID_LEN);
> -       strncpy(irmc->model, "mymodel", DID_LEN);
> +       strncpy(irmc->sn, "12345", sizeof(irmc->sn) - 1);
> +       strncpy(irmc->manu, "obex", sizeof(irmc->manu) - 1);
> +       strncpy(irmc->model, "mymodel", sizeof(irmc->model) - 1);

Not sure what is the point to use a fixed size array here? Does the
spec require it to be 18 bytes long?

-- 
Luiz Augusto von Dentz

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

* Re: [PATCH obexd 3/4] irmc: Fix length parameter of strncpy
  2012-02-02 17:29 ` Luiz Augusto von Dentz
@ 2012-02-03 12:22   ` Jaganath
  2012-02-09 11:07     ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 6+ messages in thread
From: Jaganath @ 2012-02-03 12:22 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

--------------------------------------------------
From: "Luiz Augusto von Dentz" <luiz.dentz@gmail.com>
Sent: Thursday, February 02, 2012 10:59 PM
To: "Jaganath Kanakkassery" <jaganath.k@samsung.com>
Cc: <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH obexd 3/4] irmc: Fix length parameter of strncpy

> Hi Jaganath,
>
> On Thu, Feb 2, 2012 at 3:34 AM, Jaganath Kanakkassery
> <jaganath.k@samsung.com> wrote:
>> ---
>>  plugins/irmc.c |    6 +++---
>>  1 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/plugins/irmc.c b/plugins/irmc.c
>> index 6f28e51..8344a47 100644
>> --- a/plugins/irmc.c
>> +++ b/plugins/irmc.c
>> @@ -215,9 +215,9 @@ static void *irmc_connect(struct obex_session *os, 
>> int *err)
>>         * For now lets used hostname and some 'random' value
>>         */
>>        gethostname(irmc->did, DID_LEN);
>> -       strncpy(irmc->sn, "12345", DID_LEN);
>> -       strncpy(irmc->manu, "obex", DID_LEN);
>> -       strncpy(irmc->model, "mymodel", DID_LEN);
>> +       strncpy(irmc->sn, "12345", sizeof(irmc->sn) - 1);
>> +       strncpy(irmc->manu, "obex", sizeof(irmc->manu) - 1);
>> +       strncpy(irmc->model, "mymodel", sizeof(irmc->model) - 1);
>
> Not sure what is the point to use a fixed size array here? Does the
> spec require it to be 18 bytes long?

I checked IRMC spec and could not find any length restriction.
For "sn" spec says "The format of the field is manufacturer dependent."
and for "manu" and "model" the acceptable value is string.

>
> -- 
> Luiz Augusto von Dentz

Regards
Jaganath 


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

* Re: [PATCH obexd 3/4] irmc: Fix length parameter of strncpy
  2012-02-02 11:34 [PATCH obexd 3/4] irmc: Fix length parameter of strncpy Jaganath Kanakkassery
  2012-02-02 17:29 ` Luiz Augusto von Dentz
@ 2012-02-09 11:03 ` Johan Hedberg
  1 sibling, 0 replies; 6+ messages in thread
From: Johan Hedberg @ 2012-02-09 11:03 UTC (permalink / raw)
  To: Jaganath Kanakkassery; +Cc: linux-bluetooth

Hi Jaganath,

On Thu, Feb 02, 2012, Jaganath Kanakkassery wrote:
> ---
>  plugins/irmc.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)

This patch has now also been applied.

Johan

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

* Re: [PATCH obexd 3/4] irmc: Fix length parameter of strncpy
  2012-02-03 12:22   ` Jaganath
@ 2012-02-09 11:07     ` Luiz Augusto von Dentz
  2012-02-09 11:16       ` Jaganath
  0 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-02-09 11:07 UTC (permalink / raw)
  To: Jaganath; +Cc: linux-bluetooth

Hi Jaganath,

On Fri, Feb 3, 2012 at 2:22 PM, Jaganath <jaganath.k@samsung.com> wrote:
> I checked IRMC spec and could not find any length restriction.
> For "sn" spec says "The format of the field is manufacturer dependent."
> and for "manu" and "model" the acceptable value is string.

The patch is not exactly wrong, but I fear that if we really start
reading this information from somewhere, which I guess it is whole
point here, then this fixed length may need some change.

-- 
Luiz Augusto von Dentz

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

* Re: [PATCH obexd 3/4] irmc: Fix length parameter of strncpy
  2012-02-09 11:07     ` Luiz Augusto von Dentz
@ 2012-02-09 11:16       ` Jaganath
  0 siblings, 0 replies; 6+ messages in thread
From: Jaganath @ 2012-02-09 11:16 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

--------------------------------------------------
From: "Luiz Augusto von Dentz" <luiz.dentz@gmail.com>
Sent: Thursday, February 09, 2012 4:37 PM
To: "Jaganath" <jaganath.k@samsung.com>
Cc: <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH obexd 3/4] irmc: Fix length parameter of strncpy

> Hi Jaganath,
>
> On Fri, Feb 3, 2012 at 2:22 PM, Jaganath <jaganath.k@samsung.com> wrote:
>> I checked IRMC spec and could not find any length restriction.
>> For "sn" spec says "The format of the field is manufacturer dependent."
>> and for "manu" and "model" the acceptable value is string.
>
> The patch is not exactly wrong, but I fear that if we really start
> reading this information from somewhere, which I guess it is whole
> point here, then this fixed length may need some change.

Correct. This patch is just a fix to a static tool reported issue

Regards
Jaganath

> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" 
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html 


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

end of thread, other threads:[~2012-02-09 11:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-02 11:34 [PATCH obexd 3/4] irmc: Fix length parameter of strncpy Jaganath Kanakkassery
2012-02-02 17:29 ` Luiz Augusto von Dentz
2012-02-03 12:22   ` Jaganath
2012-02-09 11:07     ` Luiz Augusto von Dentz
2012-02-09 11:16       ` Jaganath
2012-02-09 11:03 ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).