From: Dhaval Giani Date: Sat, 9 Aug 2008 09:23:56 +0000 (+0000) Subject: libcgroup: Fix segmentation fault in cgroup_init() -take2 X-Git-Tag: v0.34~263 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db00ec5091a3ab9dd994b6366a57aa7ddfa196e5;p=thirdparty%2Flibcgroup.git libcgroup: Fix segmentation fault in cgroup_init() -take2 An artifact from the time when libcgroup could not handle multiple cgroup filesystems mounted at multiple points. It is very much possible a subsystem is not mounted at that point. (FWIW, it is wrong even on a single mount point, but I am quite surprised that no one hit it yet.) V1->V2 A minor cleanup possible. Signed-off-by: Dhaval Giani git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@120 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- diff --git a/api.c b/api.c index 17e9d675..a170e634 100644 --- a/api.c +++ b/api.c @@ -193,9 +193,13 @@ int cgroup_init() if (!strcmp(ent->mnt_type, "cgroup")) { for (i = 0; controllers[i] != NULL; i++) { mntopt = hasmntopt(ent, controllers[i]); + + if (!mntopt) + continue; + mntopt = strtok_r(mntopt, ",", &strtok_buffer); - if (mntopt && - strcmp(mntopt, controllers[i]) == 0) { + + if (strcmp(mntopt, controllers[i]) == 0) { dbg("matched %s:%s\n", mntopt, controllers[i]); strcpy(cg_mount_table[found_mnt].name,