From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 03/12] bridge: netfilter: using strlcpy() instead of strncpy()
Date: Wed, 5 Jun 2013 22:40:24 +0200 [thread overview]
Message-ID: <1370464832-4216-4-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1370464832-4216-1-git-send-email-pablo@netfilter.org>
From: Chen Gang <gang.chen@asianux.com>
'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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/bridge/netfilter/ebtables.c | 6 +++---
1 file 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.10.4
next prev parent reply other threads:[~2013-06-05 20:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-05 20:40 [PATCH 00/12] Netfilter/IPVS updates for net-next Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 01/12] netfilter: xt_CT: optimize XT_CT_NOTRACK Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 02/12] netfilter: xt_socket: use IP early demux Pablo Neira Ayuso
2013-06-05 20:40 ` Pablo Neira Ayuso [this message]
2013-06-05 20:40 ` [PATCH 04/12] netfilter: don't panic on error while walking through the init path Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 05/12] netfilter: {ipt,ebt}_ULOG: rise warning on deprecation Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 06/12] sched: add cond_resched_rcu() helper Pablo Neira Ayuso
2013-06-12 15:50 ` Paul E. McKenney
2013-06-05 20:40 ` [PATCH 07/12] ipvs: use cond_resched_rcu() helper when walking connections Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 08/12] ipvs: change type of netns_ipvs->sysctl_sync_qlen_max Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 10/12] netfilter: Implement RFC 1123 for FTP conntrack Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 11/12] netfilter: nfnetlink_queue: cleanup copy_range usage Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 12/12] netfilter: nfnetlink_queue: only add CAP_LEN attr when needed Pablo Neira Ayuso
2013-06-06 9:03 ` [PATCH 00/12] Netfilter/IPVS updates for net-next David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1370464832-4216-4-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).