summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>2009-06-03 15:01:56 +0900
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2009-06-08 13:26:31 +0530
commitaec29957a768c7850ec5552ed4f31f44c4e366b2 (patch)
treee31679c82cc6777803b7fce8b9f650e79382aef3
parentafd74c4491154c5914aedbcc4e2e4acc82784b9d (diff)
downloadlibcg-aec29957a768c7850ec5552ed4f31f44c4e366b2.tar.gz
libcg-aec29957a768c7850ec5552ed4f31f44c4e366b2.tar.xz
libcg-aec29957a768c7850ec5552ed4f31f44c4e366b2.zip
Cleanup: Remove unnecessary strlen() in strncpy().
Hi, CHANGELOG of v2: ================ * Specify the buffer size of 'user' instead of strlen(). It actually walks through 'user' twice, once to compute length by strlen() and then this patch specifies the buffer size of 'user' instead. Reported-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Reviewed-By: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
-rw-r--r--src/api.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/api.c b/src/api.c
index 4f88d20..43f08d0 100644
--- a/src/api.c
+++ b/src/api.c
@@ -476,8 +476,9 @@ static int cgroup_parse_rules(bool cache, uid_t muid, gid_t mgid)
newrule->uid = uid;
newrule->gid = gid;
- strncpy(newrule->name, user, strlen(user));
- strncpy(newrule->destination, destination, strlen(destination));
+ strncpy(newrule->name, user, sizeof(newrule->name) - 1);
+ strncpy(newrule->destination, destination,
+ sizeof(newrule->destination) - 1);
newrule->next = NULL;
/* Parse the controller list, and add that to newrule too. */