From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] PR29613, use of uninitialized value in objcopy
Date: Mon, 26 Sep 2022 09:55:57 +0000 (GMT) [thread overview]
Message-ID: <20220926095557.E56123858291@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c7afb87bea33c27c7e669b94275fb8c22d6f43bc
commit c7afb87bea33c27c7e669b94275fb8c22d6f43bc
Author: Alan Modra <amodra@gmail.com>
Date: Mon Sep 26 18:25:24 2022 +0930
PR29613, use of uninitialized value in objcopy
PR 29613
* elf.c (_bfd_elf_write_secondary_reloc_section): Trim sh_size
back to relocs written. Use better types for vars.
Diff:
---
bfd/elf.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/bfd/elf.c b/bfd/elf.c
index 9a0bc1d2740..396b56db024 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -13482,9 +13482,9 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd, asection *sec)
{
asymbol * last_sym;
int last_sym_idx;
- unsigned int reloc_count;
- unsigned int idx;
- unsigned int entsize;
+ size_t reloc_count;
+ size_t idx;
+ bfd_size_type entsize;
arelent * src_irel;
bfd_byte * dst_rela;
@@ -13525,7 +13525,8 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd, asection *sec)
}
reloc_count = hdr->sh_size / entsize;
- if (reloc_count <= 0)
+ hdr->sh_size = entsize * reloc_count;
+ if (reloc_count == 0)
{
_bfd_error_handler
/* xgettext:c-format */
@@ -13572,7 +13573,7 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd, asection *sec)
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%pB(%pA): error: reloc table entry %u is empty"),
+ (_("%pB(%pA): error: reloc table entry %zu is empty"),
abfd, relsec, idx);
bfd_set_error (bfd_error_bad_value);
result = false;
@@ -13597,7 +13598,7 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd, asection *sec)
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%pB(%pA): error: secondary reloc %u"
+ (_("%pB(%pA): error: secondary reloc %zu"
" references a missing symbol"),
abfd, relsec, idx);
bfd_set_error (bfd_error_bad_value);
@@ -13615,7 +13616,7 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd, asection *sec)
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%pB(%pA): error: secondary reloc %u"
+ (_("%pB(%pA): error: secondary reloc %zu"
" references a deleted symbol"),
abfd, relsec, idx);
bfd_set_error (bfd_error_bad_value);
@@ -13629,7 +13630,7 @@ _bfd_elf_write_secondary_reloc_section (bfd *abfd, asection *sec)
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%pB(%pA): error: secondary reloc %u"
+ (_("%pB(%pA): error: secondary reloc %zu"
" is of an unknown type"),
abfd, relsec, idx);
bfd_set_error (bfd_error_bad_value);
reply other threads:[~2022-09-26 9:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220926095557.E56123858291@sourceware.org \
--to=amodra@sourceware.org \
--cc=bfd-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).