All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/net/wireless/iwlegacy: use strlcpy instead of strncpy
@ 2013-01-07  4:42 Chen Gang
  2013-01-07 11:17 ` Stanislaw Gruszka
  2013-01-20  9:31   ` Chen Gang
  0 siblings, 2 replies; 6+ messages in thread
From: Chen Gang @ 2013-01-07  4:42 UTC (permalink / raw)
  To: sgruszka, linville; +Cc: linux-wireless, netdev


  The fields must be null-terminated, or simple_strtoul will cause issue.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 drivers/net/wireless/iwlegacy/3945-mac.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
index d604b40..3726cd6 100644
--- a/drivers/net/wireless/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
@@ -3273,7 +3273,7 @@ il3945_store_measurement(struct device *d, struct device_attribute *attr,
 
 	if (count) {
 		char *p = buffer;
-		strncpy(buffer, buf, min(sizeof(buffer), count));
+		strlcpy(buffer, buf, sizeof(buffer));
 		channel = simple_strtoul(p, NULL, 0);
 		if (channel)
 			params.channel = channel;
-- 
1.7.10.4

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

* Re: [PATCH] drivers/net/wireless/iwlegacy: use strlcpy instead of strncpy
  2013-01-07  4:42 [PATCH] drivers/net/wireless/iwlegacy: use strlcpy instead of strncpy Chen Gang
@ 2013-01-07 11:17 ` Stanislaw Gruszka
  2013-01-10  8:48   ` Chen Gang F T
  2013-01-20  9:31   ` Chen Gang
  1 sibling, 1 reply; 6+ messages in thread
From: Stanislaw Gruszka @ 2013-01-07 11:17 UTC (permalink / raw)
  To: Chen Gang; +Cc: linville, linux-wireless, netdev

On Mon, Jan 07, 2013 at 12:42:46PM +0800, Chen Gang wrote:
> 
>   The fields must be null-terminated, or simple_strtoul will cause issue.
> 
> Signed-off-by: Chen Gang <gang.chen@asianux.com>

ACK


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

* Re: [PATCH] drivers/net/wireless/iwlegacy: use strlcpy instead of strncpy
  2013-01-07 11:17 ` Stanislaw Gruszka
@ 2013-01-10  8:48   ` Chen Gang F T
  0 siblings, 0 replies; 6+ messages in thread
From: Chen Gang F T @ 2013-01-10  8:48 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: Chen Gang, linville, linux-wireless, netdev

[-- Attachment #1: Type: text/plain, Size: 181 bytes --]

于 2013年01月07日 19:17, Stanislaw Gruszka 写道:
>> > Signed-off-by: Chen Gang <gang.chen@asianux.com>
> ACK

  thank you very much.

  :-)

-- 
Chen Gang

Flying Transformer

[-- Attachment #2: chen_gang_flying_transformer.vcf --]
[-- Type: text/x-vcard, Size: 67 bytes --]

begin:vcard
fn:Chen Gang
n:;Chen Gang
version:2.1
end:vcard


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

* Re: [PATCH] drivers/net/wireless/iwlegacy: use strlcpy instead of strncpy
@ 2013-01-20  9:31   ` Chen Gang
  0 siblings, 0 replies; 6+ messages in thread
From: Chen Gang @ 2013-01-20  9:31 UTC (permalink / raw)
  To: sgruszka, linville; +Cc: linux-wireless, netdev

Hello all:

  sorry, after checking the details:
    I think this patch is incorrect.
      we can not assume that the parameter "char *buf" is terminated by '\0'
      so we should only use strlcpy instead of strncpy, without touching 'min(...'

  since it is already integrated into main branch (at least, in next-20130118).
    I should send additional patch to fix it.

  please help to check, thanks.


gchen.


于 2013年01月07日 12:42, Chen Gang 写道:
> 
>   The fields must be null-terminated, or simple_strtoul will cause issue.
> 
> Signed-off-by: Chen Gang <gang.chen@asianux.com>
> ---
>  drivers/net/wireless/iwlegacy/3945-mac.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
> index d604b40..3726cd6 100644
> --- a/drivers/net/wireless/iwlegacy/3945-mac.c
> +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
> @@ -3273,7 +3273,7 @@ il3945_store_measurement(struct device *d, struct device_attribute *attr,
>  
>  	if (count) {
>  		char *p = buffer;
> -		strncpy(buffer, buf, min(sizeof(buffer), count));
> +		strlcpy(buffer, buf, sizeof(buffer));
>  		channel = simple_strtoul(p, NULL, 0);
>  		if (channel)
>  			params.channel = channel;
> 


-- 
Chen Gang

Asianux Corporation

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

* Re: [PATCH] drivers/net/wireless/iwlegacy: use strlcpy instead of strncpy
@ 2013-01-20  9:31   ` Chen Gang
  0 siblings, 0 replies; 6+ messages in thread
From: Chen Gang @ 2013-01-20  9:31 UTC (permalink / raw)
  To: sgruszka-H+wXaHxf7aLQT0dZR+AlfA, linville-2XuSBdqkA4R54TAoqtyWWQ
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA, netdev

Hello all:

  sorry, after checking the details:
    I think this patch is incorrect.
      we can not assume that the parameter "char *buf" is terminated by '\0'
      so we should only use strlcpy instead of strncpy, without touching 'min(...'

  since it is already integrated into main branch (at least, in next-20130118).
    I should send additional patch to fix it.

  please help to check, thanks.


gchen.


于 2013年01月07日 12:42, Chen Gang 写道:
> 
>   The fields must be null-terminated, or simple_strtoul will cause issue.
> 
> Signed-off-by: Chen Gang <gang.chen-bOixZGp5f+dBDgjK7y7TUQ@public.gmane.org>
> ---
>  drivers/net/wireless/iwlegacy/3945-mac.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
> index d604b40..3726cd6 100644
> --- a/drivers/net/wireless/iwlegacy/3945-mac.c
> +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
> @@ -3273,7 +3273,7 @@ il3945_store_measurement(struct device *d, struct device_attribute *attr,
>  
>  	if (count) {
>  		char *p = buffer;
> -		strncpy(buffer, buf, min(sizeof(buffer), count));
> +		strlcpy(buffer, buf, sizeof(buffer));
>  		channel = simple_strtoul(p, NULL, 0);
>  		if (channel)
>  			params.channel = channel;
> 


-- 
Chen Gang

Asianux Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] drivers/net/wireless/iwlegacy: use strlcpy instead of strncpy
  2013-01-20  9:31   ` Chen Gang
  (?)
@ 2013-01-20 10:45   ` Chen Gang F T
  -1 siblings, 0 replies; 6+ messages in thread
From: Chen Gang F T @ 2013-01-20 10:45 UTC (permalink / raw)
  To: Chen Gang; +Cc: sgruszka, linville, linux-wireless, netdev

[-- Attachment #1: Type: text/plain, Size: 1595 bytes --]

  oh, sorry, it is my fault.

  according to fill_write_buffer in fs/sysfs/file.c,
    we can assume that 'const char *buf' must be '\0' based string.

  please skip original reply.


gchen.

于 2013年01月20日 17:31, Chen Gang 写道:
> Hello all:
> 
>   sorry, after checking the details:
>     I think this patch is incorrect.
>       we can not assume that the parameter "char *buf" is terminated by '\0'
>       so we should only use strlcpy instead of strncpy, without touching 'min(...'
> 
>   since it is already integrated into main branch (at least, in next-20130118).
>     I should send additional patch to fix it.
> 
>   please help to check, thanks.
> 
> 
> gchen.
> 
> 
> 于 2013年01月07日 12:42, Chen Gang 写道:
>>
>>   The fields must be null-terminated, or simple_strtoul will cause issue.
>>
>> Signed-off-by: Chen Gang <gang.chen@asianux.com>
>> ---
>>  drivers/net/wireless/iwlegacy/3945-mac.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
>> index d604b40..3726cd6 100644
>> --- a/drivers/net/wireless/iwlegacy/3945-mac.c
>> +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
>> @@ -3273,7 +3273,7 @@ il3945_store_measurement(struct device *d, struct device_attribute *attr,
>>  
>>  	if (count) {
>>  		char *p = buffer;
>> -		strncpy(buffer, buf, min(sizeof(buffer), count));
>> +		strlcpy(buffer, buf, sizeof(buffer));
>>  		channel = simple_strtoul(p, NULL, 0);
>>  		if (channel)
>>  			params.channel = channel;
>>
> 
> 


-- 
Chen Gang

Flying Transformer

[-- Attachment #2: chen_gang_flying_transformer.vcf --]
[-- Type: text/x-vcard, Size: 67 bytes --]

begin:vcard
fn:Chen Gang
n:;Chen Gang
version:2.1
end:vcard


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

end of thread, other threads:[~2013-01-20 10:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-07  4:42 [PATCH] drivers/net/wireless/iwlegacy: use strlcpy instead of strncpy Chen Gang
2013-01-07 11:17 ` Stanislaw Gruszka
2013-01-10  8:48   ` Chen Gang F T
2013-01-20  9:31 ` Chen Gang
2013-01-20  9:31   ` Chen Gang
2013-01-20 10:45   ` Chen Gang F T

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.