This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: [PATCH] libdwfl: link_map.c (report_r_debug) always release memory_callback buffer.
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Wed, 05 Jun 2013 21:11:47 +0200
- Subject: Re: [PATCH] libdwfl: link_map.c (report_r_debug) always release memory_callback buffer.
On Wed, 05 Jun 2013 17:17:18 +0200, Mark Wielaard wrote:
> --- a/libdwfl/link_map.c
> +++ b/libdwfl/link_map.c
> @@ -395,12 +395,15 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata,
> if (! (*memory_callback) (dwfl, segndx,
> &buffer, &buffer_available,
> build_id_vaddr, build_id_len,
> - memory_callback_arg)
> - || memcmp (build_id_bits, buffer, build_id_len) != 0)
> + memory_callback_arg))
> + valid = false;
> + else
> {
> - /* File has valid build-id which cannot be verified
> - in memory. */
> - valid = false;
> + if (memcmp (build_id_bits, buffer, build_id_len) != 0)
> + /* File has valid build-id which cannot be verified
> + in memory. */
> + valid = false;
> + release_buffer (0);
> }
> }
>
I somehow did not notice the buffer lifetime management, thanks for the fix.
Just the comment
/* File has valid build-id which cannot be verified
in memory. */
applies to the both "valid = false;" cases, I have adjusted it below.
Thanks,
Jan
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 9ee0ab1..e000413 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2013-06-05 Mark Wielaard <mjw@redhat.com>
+
+ * link_map.c (report_r_debug): Always call release_buffer after
+ memory_callback succeeded reading build_id.
+
2013-05-30 Jan Kratochvil <jan.kratochvil@redhat.com>
* argp-std.c (parse_opt) <ARGP_KEY_SUCCESS> <opt->core> <opt->e>: Set
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c
index e752a5d..fecf616 100644
--- a/libdwfl/link_map.c
+++ b/libdwfl/link_map.c
@@ -395,12 +395,17 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata,
if (! (*memory_callback) (dwfl, segndx,
&buffer, &buffer_available,
build_id_vaddr, build_id_len,
- memory_callback_arg)
- || memcmp (build_id_bits, buffer, build_id_len) != 0)
+ memory_callback_arg))
+ /* File has valid build-id which cannot be verified
+ in memory. */
+ valid = false;
+ else
{
- /* File has valid build-id which cannot be verified
- in memory. */
- valid = false;
+ if (memcmp (build_id_bits, buffer, build_id_len) != 0)
+ /* File has valid build-id which does not match
+ the one in memory. */
+ valid = false;
+ release_buffer (0);
}
}