|
|
381f6c |
diff -rup binutils.orig/bfd/dwarf2.c binutils-2.30/bfd/dwarf2.c
|
|
|
381f6c |
--- binutils.orig/bfd/dwarf2.c 2018-09-26 15:07:47.162863937 +0100
|
|
|
381f6c |
+++ binutils-2.30/bfd/dwarf2.c 2018-09-26 15:08:50.868368183 +0100
|
|
|
381f6c |
@@ -527,6 +527,7 @@ read_section (bfd * abfd,
|
|
|
381f6c |
asection *msec;
|
|
|
381f6c |
const char *section_name = sec->uncompressed_name;
|
|
|
381f6c |
bfd_byte *contents = *section_buffer;
|
|
|
381f6c |
+ bfd_size_type amt;
|
|
|
381f6c |
|
|
|
381f6c |
/* The section may have already been read. */
|
|
|
381f6c |
if (contents == NULL)
|
|
|
381f6c |
@@ -549,7 +550,14 @@ read_section (bfd * abfd,
|
|
|
381f6c |
*section_size = msec->rawsize ? msec->rawsize : msec->size;
|
|
|
381f6c |
/* Paranoia - alloc one extra so that we can make sure a string
|
|
|
381f6c |
section is NUL terminated. */
|
|
|
381f6c |
- contents = (bfd_byte *) bfd_malloc (*section_size + 1);
|
|
|
381f6c |
+ amt = *section_size + 1;
|
|
|
381f6c |
+ if (amt == 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ bfd_set_error (bfd_error_no_memory);
|
|
|
381f6c |
+ return FALSE;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ contents = (bfd_byte *) bfd_malloc (amt);
|
|
|
381f6c |
+
|
|
|
381f6c |
if (contents == NULL)
|
|
|
381f6c |
return FALSE;
|
|
|
381f6c |
if (syms
|
|
|
381f6c |
diff -rup binutils.orig/bfd/syms.c binutils-2.30/bfd/syms.c
|
|
|
381f6c |
--- binutils.orig/bfd/syms.c 2018-09-26 15:07:47.162863937 +0100
|
|
|
381f6c |
+++ binutils-2.30/bfd/syms.c 2018-09-26 15:11:41.671038993 +0100
|
|
|
381f6c |
@@ -1035,6 +1035,10 @@ _bfd_stab_section_find_nearest_line (bfd
|
|
|
381f6c |
0, strsize))
|
|
|
381f6c |
return FALSE;
|
|
|
381f6c |
|
|
|
381f6c |
+ /* Stab strings ought to be nul terminated. Ensure the last one
|
|
|
381f6c |
+ is, to prevent running off the end of the buffer. */
|
|
|
381f6c |
+ info->strs[strsize - 1] = 0;
|
|
|
381f6c |
+
|
|
|
381f6c |
/* If this is a relocatable object file, we have to relocate
|
|
|
381f6c |
the entries in .stab. This should always be simple 32 bit
|
|
|
381f6c |
relocations against symbols defined in this object file, so
|
|
|
381f6c |
@@ -1073,7 +1077,8 @@ _bfd_stab_section_find_nearest_line (bfd
|
|
|
381f6c |
|| r->howto->bitsize != 32
|
|
|
381f6c |
|| r->howto->pc_relative
|
|
|
381f6c |
|| r->howto->bitpos != 0
|
|
|
381f6c |
- || r->howto->dst_mask != 0xffffffff)
|
|
|
381f6c |
+ || r->howto->dst_mask != 0xffffffff
|
|
|
381f6c |
+ || r->address * bfd_octets_per_byte (abfd) + 4 > stabsize)
|
|
|
381f6c |
{
|
|
|
381f6c |
_bfd_error_handler
|
|
|
381f6c |
(_("Unsupported .stab relocation"));
|
|
|
381f6c |
@@ -1195,7 +1200,8 @@ _bfd_stab_section_find_nearest_line (bfd
|
|
|
381f6c |
{
|
|
|
381f6c |
nul_fun = stab;
|
|
|
381f6c |
nul_str = str;
|
|
|
381f6c |
- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
|
|
|
381f6c |
+ if (file_name >= (char *) info->strs + strsize
|
|
|
381f6c |
+ || file_name < (char *) str)
|
|
|
381f6c |
file_name = NULL;
|
|
|
381f6c |
if (stab + STABSIZE + TYPEOFF < info->stabs + stabsize
|
|
|
381f6c |
&& *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO)
|
|
|
381f6c |
@@ -1206,7 +1212,8 @@ _bfd_stab_section_find_nearest_line (bfd
|
|
|
381f6c |
directory_name = file_name;
|
|
|
381f6c |
file_name = ((char *) str
|
|
|
381f6c |
+ bfd_get_32 (abfd, stab + STRDXOFF));
|
|
|
381f6c |
- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
|
|
|
381f6c |
+ if (file_name >= (char *) info->strs + strsize
|
|
|
381f6c |
+ || file_name < (char *) str)
|
|
|
381f6c |
file_name = NULL;
|
|
|
381f6c |
}
|
|
|
381f6c |
}
|
|
|
381f6c |
@@ -1217,7 +1224,8 @@ _bfd_stab_section_find_nearest_line (bfd
|
|
|
381f6c |
file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
|
|
|
381f6c |
/* PR 17512: file: 0c680a1f. */
|
|
|
381f6c |
/* PR 17512: file: 5da8aec4. */
|
|
|
381f6c |
- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
|
|
|
381f6c |
+ if (file_name >= (char *) info->strs + strsize
|
|
|
381f6c |
+ || file_name < (char *) str)
|
|
|
381f6c |
file_name = NULL;
|
|
|
381f6c |
break;
|
|
|
381f6c |
|
|
|
381f6c |
@@ -1226,7 +1234,8 @@ _bfd_stab_section_find_nearest_line (bfd
|
|
|
381f6c |
function_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
|
|
|
381f6c |
if (function_name == (char *) str)
|
|
|
381f6c |
continue;
|
|
|
381f6c |
- if (function_name >= (char *) info->strs + strsize)
|
|
|
381f6c |
+ if (function_name >= (char *) info->strs + strsize
|
|
|
381f6c |
+ || function_name < (char *) str)
|
|
|
381f6c |
function_name = NULL;
|
|
|
381f6c |
|
|
|
381f6c |
nul_fun = NULL;
|
|
|
381f6c |
@@ -1335,7 +1344,8 @@ _bfd_stab_section_find_nearest_line (bfd
|
|
|
381f6c |
if (val <= offset)
|
|
|
381f6c |
{
|
|
|
381f6c |
file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
|
|
|
381f6c |
- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
|
|
|
381f6c |
+ if (file_name >= (char *) info->strs + strsize
|
|
|
381f6c |
+ || file_name < (char *) str)
|
|
|
381f6c |
file_name = NULL;
|
|
|
381f6c |
*pline = 0;
|
|
|
381f6c |
}
|