Message ID | 20190131114059.GA15611@delia |
---|---|
State | New |
Headers | show |
Series | [libbacktrace] Fix .gnu_debugaltlink build-id check | expand |
On Thu, Jan 31, 2019 at 12:40 PM Tom de Vries <tdevries@suse.de> wrote: > > Hi, > > The 'debugaltlink_name_len =+ 1' bug reported in PR89136 exposes the fact that > the build-id is not verified for the .gnu_debugaltlink. > > Fix both problems. > > OK for trunk? OK. Richard. > Thanks, > - Tom > > [libbacktrace] Fix .gnu_debugaltlink build-id check > > 2019-01-31 Tom de Vries <tdevries@suse.de> > > PR libbacktrace/89136 > * elf.c (elf_add): Read build-id if with_buildid_data. Fix > 'debugaltlink_name_len =+ 1'. > > --- > libbacktrace/elf.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c > index d933052200c..f3988ec02a0 100644 > --- a/libbacktrace/elf.c > +++ b/libbacktrace/elf.c > @@ -2864,7 +2864,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, > /* Read the build ID if present. This could check for any > SHT_NOTE section with the right note name and type, but gdb > looks for a specific section name. */ > - if (!debuginfo > + if ((!debuginfo || with_buildid_data != NULL) > && !buildid_view_valid > && strcmp (name, ".note.gnu.build-id") == 0) > { > @@ -2938,7 +2938,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, > if (debugaltlink_name_len < shdr->sh_size) > { > /* Include terminating zero. */ > - debugaltlink_name_len =+ 1; > + debugaltlink_name_len += 1; > > debugaltlink_buildid_data > = debugaltlink_data + debugaltlink_name_len;
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index d933052200c..f3988ec02a0 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -2864,7 +2864,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, /* Read the build ID if present. This could check for any SHT_NOTE section with the right note name and type, but gdb looks for a specific section name. */ - if (!debuginfo + if ((!debuginfo || with_buildid_data != NULL) && !buildid_view_valid && strcmp (name, ".note.gnu.build-id") == 0) { @@ -2938,7 +2938,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor, if (debugaltlink_name_len < shdr->sh_size) { /* Include terminating zero. */ - debugaltlink_name_len =+ 1; + debugaltlink_name_len += 1; debugaltlink_buildid_data = debugaltlink_data + debugaltlink_name_len;