summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2008-08-09 09:25:22 +0000
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2008-08-09 09:25:22 +0000
commit50c907274a3e36db3b9819dc4f0e303ba903a3fa (patch)
tree0e23ae6a7c3ecbde228e5dbccbba82d4bce59ca3
parentdb00ec5091a3ab9dd994b6366a57aa7ddfa196e5 (diff)
downloadlibcg-50c907274a3e36db3b9819dc4f0e303ba903a3fa.tar.gz
libcg-50c907274a3e36db3b9819dc4f0e303ba903a3fa.tar.xz
libcg-50c907274a3e36db3b9819dc4f0e303ba903a3fa.zip
libcgroup: Fix index values in cgroup_add_value_*
There is a horrible bug in wrapper.c. The loop was causing a segmentation fault. This is because we were checking for index value as opposed to i. This bug was not hit before, because in all our testing, we were trying out only with CONFIG_FAIR_GROUP_SCHED and we were setting only one value inside the memory subsystem. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@121 4f4bb910-9a46-0410-90c8-c897d4f1cd53
-rw-r--r--wrapper.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/wrapper.c b/wrapper.c
index 3503194..7fa85d3 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -112,8 +112,7 @@ int cgroup_add_value_string(struct cgroup_controller *controller,
return ECGMAXVALUESEXCEEDED;
for (i = 0; i < controller->index && i < CG_VALUE_MAX; i++) {
- if (strncmp(controller->values[controller->index]->name, name,
- sizeof(controller->values[controller->index]->name)) == 0)
+ if (!strcmp(controller->values[i]->name, name))
return ECGVALUEEXISTS;
}
@@ -142,8 +141,7 @@ int cgroup_add_value_int64(struct cgroup_controller *controller,
return ECGMAXVALUESEXCEEDED;
for (i = 0; i < controller->index && i < CG_VALUE_MAX; i++) {
- if (strncmp(controller->values[controller->index]->name, name,
- sizeof(controller->values[controller->index]->name)) == 0)
+ if (!strcmp(controller->values[i]->name, name))
return ECGVALUEEXISTS;
}
@@ -178,8 +176,7 @@ int cgroup_add_value_uint64(struct cgroup_controller *controller,
return ECGMAXVALUESEXCEEDED;
for (i = 0; i < controller->index && i < CG_VALUE_MAX; i++) {
- if (strncmp(controller->values[controller->index]->name, name,
- sizeof(controller->values[controller->index]->name)) == 0)
+ if (!strcmp(controller->values[i]->name, name))
return ECGVALUEEXISTS;
}
@@ -212,8 +209,7 @@ int cgroup_add_value_bool(struct cgroup_controller *controller,
return ECGMAXVALUESEXCEEDED;
for (i = 0; i < controller->index && i < CG_VALUE_MAX; i++) {
- if (strncmp(controller->values[controller->index]->name, name,
- sizeof(controller->values[controller->index]->name)) == 0)
+ if (!strcmp(controller->values[i]->name, name))
return ECGVALUEEXISTS;
}