* Possible memory leak in auparse_interpret_sock_parts()
@ 2019-06-21 11:34 Tarun Ramesh
2019-06-21 13:11 ` Steve Grubb
0 siblings, 1 reply; 2+ messages in thread
From: Tarun Ramesh @ 2019-06-21 11:34 UTC (permalink / raw)
To: linux-audit
[-- Attachment #1.1: Type: text/plain, Size: 734 bytes --]
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.
Thanks,
Tarun
[-- Attachment #1.2: Type: text/html, Size: 1022 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Possible memory leak in auparse_interpret_sock_parts()
2019-06-21 11:34 Possible memory leak in auparse_interpret_sock_parts() Tarun Ramesh
@ 2019-06-21 13:11 ` Steve Grubb
0 siblings, 0 replies; 2+ messages in thread
From: Steve Grubb @ 2019-06-21 13:11 UTC (permalink / raw)
To: linux-audit; +Cc: Tarun Ramesh
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-21 13:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-21 11:34 Possible memory leak in auparse_interpret_sock_parts() Tarun Ramesh
2019-06-21 13:11 ` Steve Grubb
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).