* Another libselinux patch fixing memory leaks
@ 2007-02-20 15:13 Steve G
2007-02-22 14:01 ` Stephen Smalley
0 siblings, 1 reply; 2+ messages in thread
From: Steve G @ 2007-02-20 15:13 UTC (permalink / raw)
To: selinux
[-- Attachment #1: Type: text/plain, Size: 577 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 3536998516-libselinux-2.0.0-leaks.patch --]
[-- Type: text/x-patch; name="libselinux-2.0.0-leaks.patch", Size: 1327 bytes --]
diff -urp libselinux-2.0.0.orig/src/matchpathcon.c libselinux-2.0.0/src/matchpathcon.c
--- libselinux-2.0.0.orig/src/matchpathcon.c 2007-02-19 20:57:53.000000000 -0500
+++ libselinux-2.0.0/src/matchpathcon.c 2007-02-19 21:11:11.000000000 -0500
@@ -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)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Another libselinux patch fixing memory leaks
2007-02-20 15:13 Another libselinux patch fixing memory leaks Steve G
@ 2007-02-22 14:01 ` Stephen Smalley
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Smalley @ 2007-02-22 14:01 UTC (permalink / raw)
To: Steve G; +Cc: selinux
On Tue, 2007-02-20 at 07:13 -0800, Steve G wrote:
> 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.
--
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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-02-22 14:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-20 15:13 Another libselinux patch fixing memory leaks Steve G
2007-02-22 14:01 ` Stephen Smalley
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.