aboutsummaryrefslogtreecommitdiff
path: root/bfd/coffcode.h
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-02-03 09:04:21 +0000
committerNick Clifton <nickc@redhat.com>2017-02-03 09:04:21 +0000
commit1b7e3d2fb7036ce6f9d74e32dc052518f5cd45b6 (patch)
treec688cc3b7f56099d9e92a92af400fd1cbccf920b /bfd/coffcode.h
parent65c40c956fcd9443a5390d6cc36f84bd1bf77df4 (diff)
downloadgdb-1b7e3d2fb7036ce6f9d74e32dc052518f5cd45b6.zip
gdb-1b7e3d2fb7036ce6f9d74e32dc052518f5cd45b6.tar.gz
gdb-1b7e3d2fb7036ce6f9d74e32dc052518f5cd45b6.tar.bz2
Fix compile time warning messages when compiling binutils with gcc 7.0.1.
PR 21096 bfd * coffcode.h (coff_write_object_contents): Enlarge size of s_name_buf in order to avoid compile time warning about possible integer truncation. * elf32-nds32.c (nds32_elf_ex9_import_table): Mask off lower 32-bits of insn value before printing into buffer. opcodes * aarch64-opc.c (print_register_list): Ensure that the register list index will fir into the tb buffer. (print_register_offset_address): Likewise. * tic6x-dis.c (print_insn_tic6x): Increase size of func_unit_buf.
Diffstat (limited to 'bfd/coffcode.h')
-rw-r--r--bfd/coffcode.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 2ef4e92..975d249 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -3755,7 +3755,9 @@ coff_write_object_contents (bfd * abfd)
NUL-terminated. We use a temporary buffer so that we can still
sprintf all eight chars without splatting a terminating NUL
over the first byte of the following member (s_paddr). */
- char s_name_buf[SCNNMLEN + 1];
+ /* PR 21096: The +20 is to stop a bogus warning from gcc7 about
+ a possible buffer overflow. */
+ char s_name_buf[SCNNMLEN + 1 + 20];
/* An inherent limitation of the /nnnnnnn notation used to indicate
the offset of the long name in the string table is that we
@@ -3770,9 +3772,10 @@ coff_write_object_contents (bfd * abfd)
return FALSE;
}
- /* snprintf not strictly necessary now we've verified the value
- has less than eight ASCII digits, but never mind. */
- snprintf (s_name_buf, SCNNMLEN + 1, "/%lu", (unsigned long) string_size);
+ /* We do not need to use snprintf here as we have already verfied
+ that string_size is not too big, plus we have an overlarge
+ buffer, just in case. */
+ sprintf (s_name_buf, "/%lu", (unsigned long) string_size);
/* Then strncpy takes care of any padding for us. */
strncpy (section.s_name, s_name_buf, SCNNMLEN);
string_size += len + 1;