diff --git a/src/plugins/task/cgroup/task_cgroup_cpuset.c b/src/plugins/task/cgroup/task_cgroup_cpuset.c
index a9d1deccde531c4ffa604e06d21c9a3330f1535c..a4abc312c126447dee90c4d559c28c660a9e9732 100644
--- a/src/plugins/task/cgroup/task_cgroup_cpuset.c
+++ b/src/plugins/task/cgroup/task_cgroup_cpuset.c
@@ -180,7 +180,7 @@ static int _xcgroup_cpuset_init(xcgroup_t* cg)
 
 	/* load ancestor cg */
 	acg_name = (char *)xstrdup(cg->name);
-	p = rindex(acg_name, '/');
+	p = xstrrchr(acg_name, '/');
 	if (p == NULL) {
 		debug2("task/cgroup: unable to get ancestor path for "
 		       "cpuset cg '%s' : %m", cg->path);
diff --git a/src/slurmd/common/slurmd_cgroup.c b/src/slurmd/common/slurmd_cgroup.c
index 95cdf80f74217e06591a6024a08d33a2673c5f05..e76c0080c4abdd1a01d36cfbec4c24a5386fcbc1 100644
--- a/src/slurmd/common/slurmd_cgroup.c
+++ b/src/slurmd/common/slurmd_cgroup.c
@@ -378,7 +378,7 @@ static int _xcgroup_cpuset_init(xcgroup_t* cg)
 
 	/* load ancestor cg */
 	acg_name = (char*) xstrdup(cg->name);
-	p = rindex(acg_name,'/');
+	p = xstrrchr(acg_name, '/');
 	if (p == NULL) {
 		debug2("system cgroup: unable to get ancestor path for "
 		       "cpuset cg '%s' : %m", cg->path);