diff options
author | Aaron Merey <amerey@redhat.com> | 2019-11-22 13:01:03 -0500 |
---|---|---|
committer | Aaron Merey <amerey@redhat.com> | 2019-11-22 13:01:03 -0500 |
commit | 32bece07be30ba201832a44cbe549dbdef1a607f (patch) | |
tree | 5e4bdd116772f1d73060168a1f3ed37d11b1d37b | |
parent | eb5b18bf6f06197d60829ec75a0304ef011bcfc7 (diff) | |
download | binutils-gdb-32bece07be30ba201832a44cbe549dbdef1a607f.tar.gz |
debuginfod, binutils: null-terminate build-id hex strings
-rw-r--r-- | binutils/dwarf.c | 1 | ||||
-rw-r--r-- | binutils/objdump.c | 4 | ||||
-rw-r--r-- | binutils/readelf.c | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c index e269dee913e..18fabf78b36 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -10286,6 +10286,7 @@ debuginfod_fetch_separate_debug_info (struct dwarf_section * section, if (strcmp (section->uncompressed_name, ".gnu_debuglink") == 0) { + /* Get the build-id of file. */ build_id = get_build_id (file); build_id_len = 0; } diff --git a/binutils/objdump.c b/binutils/objdump.c index c20913cb701..21209f3d5c6 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -2928,11 +2928,11 @@ open_debug_file (const char * pathname) unsigned char * get_build_id (void * data) { + unsigned i; char * build_id_str; bfd * abfd = (bfd *) data; const struct bfd_build_id * build_id; - unsigned i; build_id = abfd->build_id; if (build_id == NULL) return NULL; @@ -2943,8 +2943,8 @@ get_build_id (void * data) for (i = 0; i < build_id->size; i++) sprintf(build_id_str + (i * 2), "%02x", build_id->data[i]); + build_id_str[build_id->size * 2] = '\0'; - build_id_str[build_id->size * 2 + 1] = '\0'; return (unsigned char *)build_id_str; } #endif /* HAVE_LIBDEBUGINFOD */ diff --git a/binutils/readelf.c b/binutils/readelf.c index 825000e5ff9..fa7d2b52838 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -14177,6 +14177,7 @@ load_specific_debug_section (enum dwarf_section_display_enum debug, } #if HAVE_LIBDEBUGINFOD +/* Return a hex string representation of the build-id. */ unsigned char * get_build_id (void * data) { @@ -14297,6 +14298,7 @@ get_build_id (void * data) for (j = 0; j < inote.descsz; ++j) sprintf(build_id + (j * 2), "%02x", inote.descdata[j] & 0xff); + build_id[inote.descsz * 2] = '\0'; return (unsigned char *)build_id; } |