All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Grubb <sgrubb@redhat.com>
To: linux-audit@redhat.com
Cc: Tarun Ramesh <tramesh@acalvio.com>
Subject: Re: Possible memory leak in auparse_interpret_sock_parts()
Date: Fri, 21 Jun 2019 09:11:07 -0400	[thread overview]
Message-ID: <5831426.LfvxvhjaId@x2> (raw)
In-Reply-To: <CAFQMB-Xnu+sLdi=v7ybPYogoa=_zWmkLsAvVpEK3frwXEui6RQ@mail.gmail.com>

On Friday, June 21, 2019 7:34:12 AM EDT Tarun Ramesh wrote:
> Hi,
> 
> In the function auparse_interpret_sock_parts() in auparse/auparse.c, for
> the line:
> const char *val = nvlist_interp_cur_val(r, au->escape_mode);
> 
> I see that the function nvlist_interp_cur_val() eventually calls
> auparse_do_interpretation() which has the comment "Returns a malloc'ed
> buffer that the caller must free"
> The call path is:
> nvlist_interp_cur_val() -> interpret() -> auparse_do_interpretation()
> 
> In auparse_interpret_sock_parts():
> const char *val = nvlist_interp_cur_val(r, au->escape_mode);
> is called and then the value of 'val' is overwritten by:
> val = strstr(tmp, field);
> 
> The initial memory pointed to by 'val' is never freed, which might be a
> memory leak.
> Please let me know if I;m missing something.

nvlist_interp_cur_val() maintains custody of that chunk of memory and frees 
it when the list is cleared. I have a testcase for this and valgrind is 
showing no leaks.

-Steve

      reply	other threads:[~2019-06-21 13:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-21 11:34 Possible memory leak in auparse_interpret_sock_parts() Tarun Ramesh
2019-06-21 13:11 ` Steve Grubb [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5831426.LfvxvhjaId@x2 \
    --to=sgrubb@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=tramesh@acalvio.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.