diff mbox

ARM:mach-msm: seting tail NUL after strncpy

Message ID 5108A913.6080304@asianux.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chen Gang Jan. 30, 2013, 5:01 a.m. UTC
temp need NUL terminated, or next ptr may cause issue.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 arch/arm/mach-msm/clock-debug.c |    2 ++
 1 file changed, 2 insertions(+)

Comments

Bjørn Mork Jan. 30, 2013, 9:19 a.m. UTC | #1
Chen Gang <gang.chen@asianux.com> writes:

>   temp need NUL terminated, or next ptr may cause issue.
>
> Signed-off-by: Chen Gang <gang.chen@asianux.com>
> ---
>  arch/arm/mach-msm/clock-debug.c |    2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/arm/mach-msm/clock-debug.c
> b/arch/arm/mach-msm/clock-debug.c
> index 4886404..bdca900 100644
> --- a/arch/arm/mach-msm/clock-debug.c
> +++ b/arch/arm/mach-msm/clock-debug.c
> @@ -105,6 +105,8 @@ int __init clock_debug_add(struct clk *clock)
>  		return -ENOMEM;
>
>  	strncpy(temp, clock->dbg_name, ARRAY_SIZE(temp)-1);
> +	temp[ARRAY_SIZE(temp)-1] = '\0';
> +
>  	for (ptr = temp; *ptr; ptr++)
>  		*ptr = tolower(*ptr);

Maybe use strlcpy() instead?


Bjørn
Chen Gang Jan. 30, 2013, 10:46 a.m. UTC | #2
? 2013?01?30? 17:19, Bjørn Mork ??:
> Maybe use strlcpy() instead?

  ok, I will send patch v2.

  it will be "strlcpy(temp, clock->dbg_name, ARRAY_SIZE(temp));"


  thanks.
David Brown Jan. 30, 2013, 9:33 p.m. UTC | #3
Chen Gang <gang.chen@asianux.com> writes:

>   temp need NUL terminated, or next ptr may cause issue.
>
> Signed-off-by: Chen Gang <gang.chen@asianux.com>
> ---
>  arch/arm/mach-msm/clock-debug.c |    2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/arm/mach-msm/clock-debug.c
> b/arch/arm/mach-msm/clock-debug.c
> index 4886404..bdca900 100644
> --- a/arch/arm/mach-msm/clock-debug.c
> +++ b/arch/arm/mach-msm/clock-debug.c
> @@ -105,6 +105,8 @@ int __init clock_debug_add(struct clk *clock)
>  		return -ENOMEM;
>
>  	strncpy(temp, clock->dbg_name, ARRAY_SIZE(temp)-1);
> +	temp[ARRAY_SIZE(temp)-1] = '\0';
> +
>  	for (ptr = temp; *ptr; ptr++)

I believe that Stephen Boyd is putting some significant work into this
code.  Stephen, can you see if this bug is still in your current
version of the code, and make sure that it is fixed there?

Thanks,
David
Stephen Boyd Jan. 30, 2013, 9:59 p.m. UTC | #4
On 01/30/13 13:33, David Brown wrote:
> Chen Gang <gang.chen@asianux.com> writes:
>
>>   temp need NUL terminated, or next ptr may cause issue.
>>
>> Signed-off-by: Chen Gang <gang.chen@asianux.com>
>> ---
>>  arch/arm/mach-msm/clock-debug.c |    2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/arch/arm/mach-msm/clock-debug.c
>> b/arch/arm/mach-msm/clock-debug.c
>> index 4886404..bdca900 100644
>> --- a/arch/arm/mach-msm/clock-debug.c
>> +++ b/arch/arm/mach-msm/clock-debug.c
>> @@ -105,6 +105,8 @@ int __init clock_debug_add(struct clk *clock)
>>  		return -ENOMEM;
>>
>>  	strncpy(temp, clock->dbg_name, ARRAY_SIZE(temp)-1);
>> +	temp[ARRAY_SIZE(temp)-1] = '\0';
>> +
>>  	for (ptr = temp; *ptr; ptr++)
> I believe that Stephen Boyd is putting some significant work into this
> code.  Stephen, can you see if this bug is still in your current
> version of the code, and make sure that it is fixed there?
>

This entire file is deleted in my set of patches that moves the current
MSM clock code to the common clock framework.
Chen Gang Feb. 1, 2013, 1:12 a.m. UTC | #5
? 2013?01?31? 05:59, Stephen Boyd ??:
> On 01/30/13 13:33, David Brown wrote:
>> I believe that Stephen Boyd is putting some significant work into this
>> code.  Stephen, can you see if this bug is still in your current
>> version of the code, and make sure that it is fixed there?
>>
> 
> This entire file is deleted in my set of patches that moves the current
> MSM clock code to the common clock framework.
> 

  ok, thank you.

  :-)
diff mbox

Patch

diff --git a/arch/arm/mach-msm/clock-debug.c
b/arch/arm/mach-msm/clock-debug.c
index 4886404..bdca900 100644
--- a/arch/arm/mach-msm/clock-debug.c
+++ b/arch/arm/mach-msm/clock-debug.c
@@ -105,6 +105,8 @@  int __init clock_debug_add(struct clk *clock)
 		return -ENOMEM;

 	strncpy(temp, clock->dbg_name, ARRAY_SIZE(temp)-1);
+	temp[ARRAY_SIZE(temp)-1] = '\0';
+
 	for (ptr = temp; *ptr; ptr++)
 		*ptr = tolower(*ptr);