diff options
author | Chen Gang <gang.chen@asianux.com> | 2013-05-16 18:07:22 -0400 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-05-23 05:24:57 -0400 |
commit | 8bc14d25ffb9dfc242d3a877bb4fe683adb27692 (patch) | |
tree | c7e1e671917dee9b6b5d39cc709f087e8cfbcfee | |
parent | 00028aa37098168048728acc32ab0206687f2920 (diff) |
bridge: netfilter: using strlcpy() instead of strncpy()
'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>
-rw-r--r-- | 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 3d110c4fc787..ac7802428384 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, | |||
1339 | 1339 | ||
1340 | /* ebtables expects 32 bytes long names but xt_match names are 29 bytes | 1340 | /* ebtables expects 32 bytes long names but xt_match names are 29 bytes |
1341 | long. Copy 29 bytes and fill remaining bytes with zeroes. */ | 1341 | long. Copy 29 bytes and fill remaining bytes with zeroes. */ |
1342 | strncpy(name, m->u.match->name, sizeof(name)); | 1342 | strlcpy(name, m->u.match->name, sizeof(name)); |
1343 | if (copy_to_user(hlp, name, EBT_FUNCTION_MAXNAMELEN)) | 1343 | if (copy_to_user(hlp, name, EBT_FUNCTION_MAXNAMELEN)) |
1344 | return -EFAULT; | 1344 | return -EFAULT; |
1345 | return 0; | 1345 | return 0; |
@@ -1351,7 +1351,7 @@ static inline int ebt_make_watchername(const struct ebt_entry_watcher *w, | |||
1351 | char __user *hlp = ubase + ((char *)w - base); | 1351 | char __user *hlp = ubase + ((char *)w - base); |
1352 | char name[EBT_FUNCTION_MAXNAMELEN] = {}; | 1352 | char name[EBT_FUNCTION_MAXNAMELEN] = {}; |
1353 | 1353 | ||
1354 | strncpy(name, w->u.watcher->name, sizeof(name)); | 1354 | strlcpy(name, w->u.watcher->name, sizeof(name)); |
1355 | if (copy_to_user(hlp , name, EBT_FUNCTION_MAXNAMELEN)) | 1355 | if (copy_to_user(hlp , name, EBT_FUNCTION_MAXNAMELEN)) |
1356 | return -EFAULT; | 1356 | return -EFAULT; |
1357 | return 0; | 1357 | return 0; |
@@ -1377,7 +1377,7 @@ ebt_make_names(struct ebt_entry *e, const char *base, char __user *ubase) | |||
1377 | ret = EBT_WATCHER_ITERATE(e, ebt_make_watchername, base, ubase); | 1377 | ret = EBT_WATCHER_ITERATE(e, ebt_make_watchername, base, ubase); |
1378 | if (ret != 0) | 1378 | if (ret != 0) |
1379 | return ret; | 1379 | return ret; |
1380 | strncpy(name, t->u.target->name, sizeof(name)); | 1380 | strlcpy(name, t->u.target->name, sizeof(name)); |
1381 | if (copy_to_user(hlp, name, EBT_FUNCTION_MAXNAMELEN)) | 1381 | if (copy_to_user(hlp, name, EBT_FUNCTION_MAXNAMELEN)) |
1382 | return -EFAULT; | 1382 | return -EFAULT; |
1383 | return 0; | 1383 | return 0; |