* [PATCH] bridge: netfilter: using strlcpy() instead of strncpy()
@ 2013-05-17 8:07 Chen Gang
2013-05-19 19:43 ` Bart De Schuymer
2013-05-23 10:56 ` Pablo Neira Ayuso
0 siblings, 2 replies; 5+ messages in thread
From: Chen Gang @ 2013-05-17 8:07 UTC (permalink / raw)
To: bart.de.schuymer, pablo, kaber, stephen
Cc: David Miller, netfilter-devel, netfilter, coreteam, bridge, netdev
'name' has already set all zero when it is defined, so not need let
strncpy() to pad it again.
'name' is a string, better always let is NUL terminated, so use
strlcpy() instead of strncpy().
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
net/bridge/netfilter/ebtables.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 3d110c4..ac78024 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -1339,7 +1339,7 @@ static inline int ebt_make_matchname(const struct ebt_entry_match *m,
/* ebtables expects 32 bytes long names but xt_match names are 29 bytes
long. Copy 29 bytes and fill remaining bytes with zeroes. */
- strncpy(name, m->u.match->name, sizeof(name));
+ strlcpy(name, m->u.match->name, sizeof(name));
if (copy_to_user(hlp, name, EBT_FUNCTION_MAXNAMELEN))
return -EFAULT;
return 0;
@@ -1351,7 +1351,7 @@ static inline int ebt_make_watchername(const struct ebt_entry_watcher *w,
char __user *hlp = ubase + ((char *)w - base);
char name[EBT_FUNCTION_MAXNAMELEN] = {};
- strncpy(name, w->u.watcher->name, sizeof(name));
+ strlcpy(name, w->u.watcher->name, sizeof(name));
if (copy_to_user(hlp , name, EBT_FUNCTION_MAXNAMELEN))
return -EFAULT;
return 0;
@@ -1377,7 +1377,7 @@ ebt_make_names(struct ebt_entry *e, const char *base, char __user *ubase)
ret = EBT_WATCHER_ITERATE(e, ebt_make_watchername, base, ubase);
if (ret != 0)
return ret;
- strncpy(name, t->u.target->name, sizeof(name));
+ strlcpy(name, t->u.target->name, sizeof(name));
if (copy_to_user(hlp, name, EBT_FUNCTION_MAXNAMELEN))
return -EFAULT;
return 0;
--
1.7.7.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] bridge: netfilter: using strlcpy() instead of strncpy()
2013-05-17 8:07 [PATCH] bridge: netfilter: using strlcpy() instead of strncpy() Chen Gang
@ 2013-05-19 19:43 ` Bart De Schuymer
2013-05-20 1:04 ` Chen Gang
2013-05-23 10:56 ` Pablo Neira Ayuso
1 sibling, 1 reply; 5+ messages in thread
From: Bart De Schuymer @ 2013-05-19 19:43 UTC (permalink / raw)
To: Chen Gang
Cc: bart.de.schuymer, pablo, kaber, stephen, David Miller,
netfilter-devel, netfilter, coreteam, bridge, netdev
Op 17/05/2013 10:07, Chen Gang schreef:
>
> 'name' has already set all zero when it is defined, so not need let
> strncpy() to pad it again.
>
> 'name' is a string, better always let is NUL terminated, so use
> strlcpy() instead of strncpy().
>
>
> Signed-off-by: Chen Gang <gang.chen@asianux.com>
Acked-by: Bart De Schuymer <bdschuym@pandora.be>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bridge: netfilter: using strlcpy() instead of strncpy()
2013-05-19 19:43 ` Bart De Schuymer
@ 2013-05-20 1:04 ` Chen Gang
0 siblings, 0 replies; 5+ messages in thread
From: Chen Gang @ 2013-05-20 1:04 UTC (permalink / raw)
To: Bart De Schuymer
Cc: bart.de.schuymer, pablo, kaber, stephen, David Miller,
netfilter-devel, netfilter, coreteam, bridge, netdev
On 05/20/2013 03:43 AM, Bart De Schuymer wrote:
> Op 17/05/2013 10:07, Chen Gang schreef:
>>
>> 'name' has already set all zero when it is defined, so not need let
>> strncpy() to pad it again.
>>
>> 'name' is a string, better always let is NUL terminated, so use
>> strlcpy() instead of strncpy().
>>
>>
>> Signed-off-by: Chen Gang <gang.chen@asianux.com>
> Acked-by: Bart De Schuymer <bdschuym@pandora.be>
Thanks.
--
Chen Gang
Asianux Corporation
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bridge: netfilter: using strlcpy() instead of strncpy()
2013-05-17 8:07 [PATCH] bridge: netfilter: using strlcpy() instead of strncpy() Chen Gang
2013-05-19 19:43 ` Bart De Schuymer
@ 2013-05-23 10:56 ` Pablo Neira Ayuso
2013-05-23 10:57 ` Chen Gang
1 sibling, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2013-05-23 10:56 UTC (permalink / raw)
To: Chen Gang
Cc: bart.de.schuymer, kaber, stephen, David Miller, netfilter-devel,
netfilter, coreteam, bridge, netdev
On Fri, May 17, 2013 at 04:07:22PM +0800, Chen Gang wrote:
>
> 'name' has already set all zero when it is defined, so not need let
> strncpy() to pad it again.
>
> 'name' is a string, better always let is NUL terminated, so use
> strlcpy() instead of strncpy().
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bridge: netfilter: using strlcpy() instead of strncpy()
2013-05-23 10:56 ` Pablo Neira Ayuso
@ 2013-05-23 10:57 ` Chen Gang
0 siblings, 0 replies; 5+ messages in thread
From: Chen Gang @ 2013-05-23 10:57 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: bart.de.schuymer, kaber, stephen, David Miller, netfilter-devel,
netfilter, coreteam, bridge, netdev
On 05/23/2013 06:56 PM, Pablo Neira Ayuso wrote:
> On Fri, May 17, 2013 at 04:07:22PM +0800, Chen Gang wrote:
>> >
>> > 'name' has already set all zero when it is defined, so not need let
>> > strncpy() to pad it again.
>> >
>> > 'name' is a string, better always let is NUL terminated, so use
>> > strlcpy() instead of strncpy().
> Applied, thanks.
>
>
Thank you too.
--
Chen Gang
Asianux Corporation
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-05-23 10:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-17 8:07 [PATCH] bridge: netfilter: using strlcpy() instead of strncpy() Chen Gang
2013-05-19 19:43 ` Bart De Schuymer
2013-05-20 1:04 ` Chen Gang
2013-05-23 10:56 ` Pablo Neira Ayuso
2013-05-23 10:57 ` Chen Gang
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).