diff options
author | Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> | 2009-06-03 15:01:56 +0900 |
---|---|---|
committer | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2009-06-08 13:26:31 +0530 |
commit | aec29957a768c7850ec5552ed4f31f44c4e366b2 (patch) | |
tree | e31679c82cc6777803b7fce8b9f650e79382aef3 /src/api.c | |
parent | afd74c4491154c5914aedbcc4e2e4acc82784b9d (diff) | |
download | libcg-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>
Diffstat (limited to 'src/api.c')
-rw-r--r-- | src/api.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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. */ |