[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1371725385-11540-2-git-send-email-zhaohongjiang@huawei.com>
Date: Thu, 20 Jun 2013 18:49:42 +0800
From: Zhao Hongjiang <zhaohongjiang@...wei.com>
To: <davem@...emloft.net>
CC: <kuznet@....inr.ac.ru>, <jmorris@...ei.org>,
<yoshfuji@...ux-ipv6.org>, <kaber@...sh.net>,
<netdev@...r.kernel.org>, Zhao Hongjiang <zhaohongjiang@...wei.com>
Subject: [PATCH 2/5] net: netfilter: using strlcpy instead of strncpy
for NUL terminated string, need alway set '\0' in the end.
Signed-off-by: Zhao Hongjiang <zhaohongjiang@...wei.com>
---
net/netfilter/ipset/ip_set_core.c | 12 ++++++------
net/netfilter/nfnetlink_acct.c | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index f771390..d70895b 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1010,7 +1010,7 @@ ip_set_rename(struct sock *ctnl, struct sk_buff *skb,
goto out;
}
}
- strncpy(set->name, name2, IPSET_MAXNAMELEN);
+ strlcpy(set->name, name2, sizeof(set->name));
out:
read_unlock_bh(&ip_set_ref_lock);
@@ -1055,9 +1055,9 @@ ip_set_swap(struct sock *ctnl, struct sk_buff *skb,
from->type->family == to->type->family))
return -IPSET_ERR_TYPE_MISMATCH;
- strncpy(from_name, from->name, IPSET_MAXNAMELEN);
- strncpy(from->name, to->name, IPSET_MAXNAMELEN);
- strncpy(to->name, from_name, IPSET_MAXNAMELEN);
+ strlcpy(from_name, from->name, sizeof(from_name));
+ strlcpy(from->name, to->name, sizeof(from->name));
+ strlcpy(to->name, from_name, sizeof(to->name));
write_lock_bh(&ip_set_ref_lock);
swap(from->ref, to->ref);
@@ -1800,8 +1800,8 @@ ip_set_sockfn_get(struct sock *sk, int optval, void __user *user, int *len)
}
nfnl_lock(NFNL_SUBSYS_IPSET);
set = nfnl_set(req_get->set.index);
- strncpy(req_get->set.name, set ? set->name : "",
- IPSET_MAXNAMELEN);
+ strlcpy(req_get->set.name, set ? set->name : "",
+ sizeof(req_get->set.name));
nfnl_unlock(NFNL_SUBSYS_IPSET);
goto copy;
}
diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
index c7b6d46..520247b 100644
--- a/net/netfilter/nfnetlink_acct.c
+++ b/net/netfilter/nfnetlink_acct.c
@@ -77,7 +77,7 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,
if (nfacct == NULL)
return -ENOMEM;
- strncpy(nfacct->name, nla_data(tb[NFACCT_NAME]), NFACCT_NAME_MAX);
+ strlcpy(nfacct->name, nla_data(tb[NFACCT_NAME]), sizeof(nfacct->name));
if (tb[NFACCT_BYTES]) {
atomic64_set(&nfacct->bytes,
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists