]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup: Fix index values in cgroup_add_value_*
authorDhaval Giani <dhaval@linux.vnet.ibm.com>
Sat, 9 Aug 2008 09:25:22 +0000 (09:25 +0000)
committerDhaval Giani <dhaval@linux.vnet.ibm.com>
Sat, 9 Aug 2008 09:25:22 +0000 (09:25 +0000)
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

wrapper.c

index 350319413460868ada1e1d4f306164627c38f031..7fa85d3347044fae2754352f12146ce6111e708e 100644 (file)
--- 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;
        }