diff mbox series

mcstransd: fix memory leak in new_context_str

Message ID 6f2dc066-1f5b-1ea8-be48-73ae2b977b44@gmail.com (mailing list archive)
State Accepted
Headers show
Series mcstransd: fix memory leak in new_context_str | expand

Commit Message

bauen1 May 12, 2020, 5:52 p.m. UTC
The return value of context_new needs to be free with context_free.

Signed-off-by: bauen1 <j2468h@gmail.com>
---
 mcstrans/src/mcstrans.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Roberts, William C May 12, 2020, 6:03 p.m. UTC | #1
> -----Original Message-----
> From: selinux-owner@vger.kernel.org [mailto:selinux-owner@vger.kernel.org]
> On Behalf Of bauen1
> Sent: Tuesday, May 12, 2020 12:53 PM
> To: selinux <selinux@vger.kernel.org>
> Subject: [PATCH] mcstransd: fix memory leak in new_context_str
> 
> The return value of context_new needs to be free with context_free.
> 
> Signed-off-by: bauen1 <j2468h@gmail.com>
> ---
>  mcstrans/src/mcstrans.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mcstrans/src/mcstrans.c b/mcstrans/src/mcstrans.c index
> 96bdbdff..2116b161 100644
> --- a/mcstrans/src/mcstrans.c
> +++ b/mcstrans/src/mcstrans.c
> @@ -919,6 +919,7 @@ new_context_str(const security_context_t incon, const
> char *range) {
>  	}
>  	context_range_set(con, range);
>  	rcon = strdup(context_str(con));
> +	context_free(con);
>  	if (!rcon) {
>  		goto exit;
>  	}
> --
> 2.26.2

Acked-by: William Roberts <william.c.roberts@intel.com>
Petr Lautrbach May 13, 2020, 3:12 p.m. UTC | #2
On Tue, May 12, 2020 at 07:52:54PM +0200, bauen1 wrote:
> The return value of context_new needs to be free with context_free.
> 
> Signed-off-by: bauen1 <j2468h@gmail.com>
> Acked-by: William Roberts <william.c.roberts@intel.com>

Applied.

> ---
>  mcstrans/src/mcstrans.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mcstrans/src/mcstrans.c b/mcstrans/src/mcstrans.c
> index 96bdbdff..2116b161 100644
> --- a/mcstrans/src/mcstrans.c
> +++ b/mcstrans/src/mcstrans.c
> @@ -919,6 +919,7 @@ new_context_str(const security_context_t incon, const char *range) {
>  	}
>  	context_range_set(con, range);
>  	rcon = strdup(context_str(con));
> +	context_free(con);
>  	if (!rcon) {
>  		goto exit;
>  	}
William Roberts May 13, 2020, 3:52 p.m. UTC | #3
On Wed, May 13, 2020 at 10:13 AM Petr Lautrbach <plautrba@redhat.com> wrote:
>
> On Tue, May 12, 2020 at 07:52:54PM +0200, bauen1 wrote:
> > The return value of context_new needs to be free with context_free.
> >
> > Signed-off-by: bauen1 <j2468h@gmail.com>
> > Acked-by: William Roberts <william.c.roberts@intel.com>
>
> Applied.

I updated the state to accepted in Patchwork

>
> > ---
> >  mcstrans/src/mcstrans.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/mcstrans/src/mcstrans.c b/mcstrans/src/mcstrans.c
> > index 96bdbdff..2116b161 100644
> > --- a/mcstrans/src/mcstrans.c
> > +++ b/mcstrans/src/mcstrans.c
> > @@ -919,6 +919,7 @@ new_context_str(const security_context_t incon, const char *range) {
> >       }
> >       context_range_set(con, range);
> >       rcon = strdup(context_str(con));
> > +     context_free(con);
> >       if (!rcon) {
> >               goto exit;
> >       }
>
> --
> ()  ascii ribbon campaign - against html e-mail
> /\  www.asciiribbon.org   - against proprietary attachments
diff mbox series

Patch

diff --git a/mcstrans/src/mcstrans.c b/mcstrans/src/mcstrans.c
index 96bdbdff..2116b161 100644
--- a/mcstrans/src/mcstrans.c
+++ b/mcstrans/src/mcstrans.c
@@ -919,6 +919,7 @@  new_context_str(const security_context_t incon, const char *range) {
 	}
 	context_range_set(con, range);
 	rcon = strdup(context_str(con));
+	context_free(con);
 	if (!rcon) {
 		goto exit;
 	}