Another libselinux patch fixing memory leaks
Hi,
I was running restorecond through valgrind to figure out why it consumes so much memory. It seemed to point to matchpathcon as a possible leak. I looked at the functions and saw that there are some potentially uninitialized pointers that could get freed when jumping to finish and a couple allocations that appear to be leaked.
Patch is attached.
-Steve
____________________________________________________________________________________
Never Miss an Email
Stay connected with Yahoo! Mail on your mobile. Get started!
http://mobile.yahoo.com/services?promote=mail
src/matchpathcon.c +7 -2
@@ -445,9 +445,9 @@ static int process_line(const char *path {int items, len, regerr, ret;char *buf_p, *ptr; -char *regex, *type, *context; +char *regex=NULL , *type=NULL , *context=NULL ;const char *reg_buf; -char *anchored_regex; +char *anchored_regex =NULL ; ret =0 ; len =strlen (line_buf);
@@ -543,9 +543,12 @@ static int process_line(const char *path path, lineno, anchored_regex, (errbuf ? errbuf : "out of memory"));free (anchored_regex); + anchored_regex =NULL ; +free (errbuf); goto finish; }free (anchored_regex); + anchored_regex =NULL ;/* Convert the type string to a mode format */ spec_arr[nspec].type_str = type;
@@ -718,6 +721,7 @@ int matchpathcon_init_prefix(const char } }free (line_buf); + line_buf =NULL ;/* Move exact pathname specifications to the end. */ spec_copy =malloc (sizeof (spec_t) * nspec);
@@ -740,6 +744,7 @@ int matchpathcon_init_prefix(const char status =0 ; finish:fclose (fp); +free (line_buf);if (spec_arr != spec_copy)free (spec_arr);if (homedirfp)
Quoted 9 lines · Steve G
Hi,
I was running restorecond through valgrind to figure out why it consumes so much memory. It seemed to point to matchpathcon as a possible leak. I looked at the functions and saw that there are some potentially uninitialized pointers that could get freed when jumping to finish and a couple allocations that appear to be leaked.
Patch is attached.
Thanks, merged into -trunk and -stable.
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.