* [PATCH] debuginfod: Clear and reset debuginfod_client winning_headers on reuse
@ 2021-12-04 21:54 Mark Wielaard
2021-12-06 18:41 ` Frank Ch. Eigler
0 siblings, 1 reply; 3+ messages in thread
From: Mark Wielaard @ 2021-12-04 21:54 UTC (permalink / raw)
To: elfutils-devel; +Cc: Mark Wielaard
gcc address sanitizer detected a leak of the debuginfod_client
winning_headers when the handle was reused. Make sure to free and
reset the winning_headers field before reuse.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
debuginfod/ChangeLog | 5 +++++
debuginfod/debuginfod-client.c | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index c9253d6c..e2f07f97 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,3 +1,8 @@
+2021-12-04 Mark Wielaard <mark@klomp.org>
+
+ * debuginfod-client.c (debuginfod_query_server): Free winning_headers.
+ Reset response_data_size when clearing response_data.
+
2021-12-04 Mark Wielaard <mark@klomp.org>
* debuginfod.cxx (main): Call debuginfod_pool_groom before exit.
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index c875ee62..20779d9f 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -1028,7 +1028,11 @@ debuginfod_query_server (debuginfod_client *c,
int committed_to = -1;
bool verbose_reported = false;
struct timespec start_time, cur_time;
- c->winning_headers = NULL;
+ if (c->winning_headers != NULL)
+ {
+ free (c->winning_headers);
+ c->winning_headers = NULL;
+ }
if ( maxtime > 0 && clock_gettime(CLOCK_MONOTONIC_RAW, &start_time) == -1)
{
rc = errno;
@@ -1072,6 +1076,7 @@ debuginfod_query_server (debuginfod_client *c,
if (vfd >= 0 && c->winning_headers != NULL)
dprintf(vfd, "\n%s", c->winning_headers);
data[committed_to].response_data = NULL;
+ data[committed_to].response_data_size = 0;
}
}
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] debuginfod: Clear and reset debuginfod_client winning_headers on reuse
2021-12-04 21:54 [PATCH] debuginfod: Clear and reset debuginfod_client winning_headers on reuse Mark Wielaard
@ 2021-12-06 18:41 ` Frank Ch. Eigler
2021-12-07 8:53 ` Mark Wielaard
0 siblings, 1 reply; 3+ messages in thread
From: Frank Ch. Eigler @ 2021-12-06 18:41 UTC (permalink / raw)
To: Mark Wielaard; +Cc: elfutils-devel
Hi -
> gcc address sanitizer detected a leak of the debuginfod_client
> winning_headers when the handle was reused. Make sure to free and
> reset the winning_headers field before reuse.
This is good.
(Note we're not actually using these winning_headers bits for
anything. That was to be part of the "return headers to application"
work whose API we were discussing under PR28284. I suspect it'll come
to a more thorough motivation & understanding when we try to work out
PR28204 - passing file signatures).
- FChE
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] debuginfod: Clear and reset debuginfod_client winning_headers on reuse
2021-12-06 18:41 ` Frank Ch. Eigler
@ 2021-12-07 8:53 ` Mark Wielaard
0 siblings, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2021-12-07 8:53 UTC (permalink / raw)
To: Frank Ch. Eigler; +Cc: elfutils-devel
Hi Frank,
On Mon, 2021-12-06 at 13:41 -0500, Frank Ch. Eigler wrote:
> gcc address sanitizer detected a leak of the debuginfod_client
> > winning_headers when the handle was reused. Make sure to free and
> > reset the winning_headers field before reuse.
>
> This is good.
Thanks, pushed.
Cheers,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-07 8:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-04 21:54 [PATCH] debuginfod: Clear and reset debuginfod_client winning_headers on reuse Mark Wielaard
2021-12-06 18:41 ` Frank Ch. Eigler
2021-12-07 8:53 ` Mark Wielaard
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 read-only IMAP folder(s) and NNTP newsgroup(s).