Blame SOURCES/libcgroup-0.41-fix-infinite-loop.patch

2ae3c9
From 62bab9d121d4fb416205f5ac53ad342184ae42b6 Mon Sep 17 00:00:00 2001
2ae3c9
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
2ae3c9
Date: Tue, 8 Dec 2015 16:53:41 +0100
2ae3c9
Subject: [PATCH 2/6] api.c: fix infinite loop
2ae3c9
2ae3c9
If getgrnam or getpwuid functions failed, the program entered
2ae3c9
an infinite loop, because the rule pointer was never advanced.
2ae3c9
This is now fixed by updating the pointer before continuing
2ae3c9
to the next iteration.
2ae3c9
---
2ae3c9
 src/api.c | 8 ++++++--
2ae3c9
 1 file changed, 6 insertions(+), 2 deletions(-)
2ae3c9
2ae3c9
diff --git a/src/api.c b/src/api.c
2ae3c9
index df90a6f..217d6c9 100644
2ae3c9
--- a/src/api.c
2ae3c9
+++ b/src/api.c
2ae3c9
@@ -2664,13 +2664,17 @@ static struct cgroup_rule *cgroup_find_matching_rule_uid_gid(uid_t uid,
2ae3c9
 			/* Get the group data. */
2ae3c9
 			sp = &(rule->username[1]);
2ae3c9
 			grp = getgrnam(sp);
2ae3c9
-			if (!grp)
2ae3c9
+			if (!grp) {
2ae3c9
+				rule = rule->next;
2ae3c9
 				continue;
2ae3c9
+			}
2ae3c9
 
2ae3c9
 			/* Get the data for UID. */
2ae3c9
 			usr = getpwuid(uid);
2ae3c9
-			if (!usr)
2ae3c9
+			if (!usr) {
2ae3c9
+				rule = rule->next;
2ae3c9
 				continue;
2ae3c9
+			}
2ae3c9
 
2ae3c9
 			/* If UID is a member of group, we matched. */
2ae3c9
 			for (i = 0; grp->gr_mem[i]; i++) {
2ae3c9
-- 
2ae3c9
2.17.0
2ae3c9