On Tue 12-07-11 10:30:41, Peter Schiffer wrote: > In function cgroup_parse_rules() added missing check for getpwuid() result. > In cgroup_get_procs() added missing fclose() on file descriptor. > In load_list() added missing fclose() on file descriptor. > > Signed-off-by: Peter Schiffer <pschi...@redhat.com> > --- > > src/api.c | 5 +++++ > src/tools/cgsnapshot.c | 2 ++ > 2 files changed, 7 insertions(+), 0 deletions(-) > > diff --git a/src/api.c b/src/api.c > index d5022c2..e443ad5 100644 > --- a/src/api.c > +++ b/src/api.c > @@ -637,6 +637,9 @@ static int cgroup_parse_rules(bool cache, uid_t muid, > */ > if (grp && muid != CGRULE_INVALID) { > pwd = getpwuid(muid); > + if (!pwd) { > + continue; > + }
The whole function is a complete mess so it is hard to tell whether this is OK. It seems to be correct but I am not aware of all side effects... > for (i = 0; grp->gr_mem[i]; i++) { > if (!(strcmp(pwd->pw_name, grp->gr_mem[i]))) > matched = true; > @@ -3910,6 +3913,8 @@ int cgroup_get_procs(char *name, char *controller, > pid_t **pids, int *size) > } > } > > + fclose(procs); > + > *size = n; > > qsort(tmp_list, n, sizeof(pid_t), &pid_compare); > diff --git a/src/tools/cgsnapshot.c b/src/tools/cgsnapshot.c > index 30e7b6d..404d54a 100644 > --- a/src/tools/cgsnapshot.c > +++ b/src/tools/cgsnapshot.c > @@ -146,6 +146,8 @@ int load_list(char *filename, struct black_list_type > **p_list) > } > } > > + fclose(fw); > + > *p_list = start; > return 0; These two look definitely corret. I guess it would make more sense to extract it as a separate patch - file descriptor leaks fix. You can add my Reviewed-by: Michal Hocko <mho...@suse.cz> -- Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic ------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel