]>
Commit | Line | Data |
---|---|---|
9665627f AM |
1 | From 62bab9d121d4fb416205f5ac53ad342184ae42b6 Mon Sep 17 00:00:00 2001 |
2 | From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com> | |
3 | Date: Tue, 8 Dec 2015 16:53:41 +0100 | |
4 | Subject: [PATCH 2/6] api.c: fix infinite loop | |
5 | ||
6 | If getgrnam or getpwuid functions failed, the program entered | |
7 | an infinite loop, because the rule pointer was never advanced. | |
8 | This is now fixed by updating the pointer before continuing | |
9 | to the next iteration. | |
10 | --- | |
11 | src/api.c | 8 ++++++-- | |
12 | 1 file changed, 6 insertions(+), 2 deletions(-) | |
13 | ||
14 | diff --git a/src/api.c b/src/api.c | |
15 | index df90a6f..217d6c9 100644 | |
16 | --- a/src/api.c | |
17 | +++ b/src/api.c | |
18 | @@ -2664,13 +2664,17 @@ static struct cgroup_rule *cgroup_find_matching_rule_uid_gid(uid_t uid, | |
19 | /* Get the group data. */ | |
20 | sp = &(rule->username[1]); | |
21 | grp = getgrnam(sp); | |
22 | - if (!grp) | |
23 | + if (!grp) { | |
24 | + rule = rule->next; | |
25 | continue; | |
26 | + } | |
27 | ||
28 | /* Get the data for UID. */ | |
29 | usr = getpwuid(uid); | |
30 | - if (!usr) | |
31 | + if (!usr) { | |
32 | + rule = rule->next; | |
33 | continue; | |
34 | + } | |
35 | ||
36 | /* If UID is a member of group, we matched. */ | |
37 | for (i = 0; grp->gr_mem[i]; i++) { | |
38 | -- | |
39 | 2.17.0 | |
40 |