[SSSD] [PATCH] UTIL: Free log message when using journald

Jakub Hrozek jhrozek at redhat.com
Mon Oct 21 15:32:26 UTC 2013


On Mon, Oct 21, 2013 at 10:35:34AM -0400, Simo Sorce wrote:
> On Mon, 2013-10-21 at 11:01 +0200, Jakub Hrozek wrote:
> > 
> > I was exercising sssd with valgrind when looking for #1020945 and
> > found
> > this leak.
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > plain text
> > document
> > attachment
> > (0001-UTIL-Free-log-message-when-using-journald.patch)
> > 
> > From 3bde2833eca1fc280214da03f067e3df63040899 Mon Sep 17 00:00:00 2001
> > From: Jakub Hrozek <jhrozek at redhat.com>
> > Date: Sun, 20 Oct 2013 16:52:06 +0200
> > Subject: [PATCH 2/3] UTIL: Free log message when using journald
> > 
> > ---
> >  src/util/sss_log.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/src/util/sss_log.c b/src/util/sss_log.c
> > index
> > 5be9e7f2bc1486d83393d2d105c1a73322d7f6f1..b6b922785b03f8d9673aebdeb33a83c3f6b14076 100644
> > --- a/src/util/sss_log.c
> > +++ b/src/util/sss_log.c
> > @@ -88,6 +88,8 @@ void sss_log(int priority, const char *format, ...)
> >                      "SYSLOG_FACILITY=%i", LOG_FAC(LOG_DAEMON),
> >                      "SYSLOG_IDENTIFIER=%s", debug_prg_name,
> >                      NULL);
> > +
> > +    free(message);
> >  }
> >  
> >  #else /* WITH_JOURNALD */ 
> 
> 
> Is there any reason why we are not using talloc_vasrpintf() here and
> passing in a memcontext ?
> 
> I think I would rather fix this problem that way. 
> 
> Simo.

Mostly because I copied the old syslog-based sss_log() function.

But I don't think the mem_ctx is needed, the function doesn't allocate
anything for its consumer, nor does it operate on any predictable
structure (like state or tevent_req with tevent contexts), so I would
prefer not to add a memory context to its signature.



More information about the sssd-devel mailing list