From: Dhaval Giani Date: Sat, 9 Aug 2008 09:25:22 +0000 (+0000) Subject: libcgroup: Fix index values in cgroup_add_value_* X-Git-Tag: v0.34~262 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50c907274a3e36db3b9819dc4f0e303ba903a3fa;p=thirdparty%2Flibcgroup.git 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 git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@121 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- diff --git a/wrapper.c b/wrapper.c index 35031941..7fa85d33 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; }