aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2021-02-08 18:31:21 +0000
committerNick Clifton <nickc@redhat.com>2021-02-08 18:31:21 +0000
commit80b652efa2e969d865d06e1a4aec16b4dcd9f435 (patch)
tree45cd6d47cba989f88c71a84219ae0c9ea607cb21 /gas
parent4001d90ddecdfc0e89daa4eca17006e20ad626c0 (diff)
downloadbinutils-80b652efa2e969d865d06e1a4aec16b4dcd9f435.zip
binutils-80b652efa2e969d865d06e1a4aec16b4dcd9f435.tar.gz
binutils-80b652efa2e969d865d06e1a4aec16b4dcd9f435.tar.bz2
Fix an illegal memory access when parsing a corrupt assembler file.
PR 27355 * dwarf2dbg.c (allocate_filename_to_slot): Allocate the dirs array if it has not already been created.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog6
-rw-r--r--gas/dwarf2dbg.c12
2 files changed, 16 insertions, 2 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 3d55c7f..83b2721 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2021-02-08 Nick Clifton <nickc@redhat.com>
+
+ PR 27355
+ * dwarf2dbg.c (allocate_filename_to_slot): Allocate the dirs array
+ if it has not already been created.
+
2021-02-04 Nelson Chu <nelson.chu@sifive.com>
* config/tc-riscv.c (riscv_multi_subset_supports): Removed
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 4fbd1e3..f0cdc23 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -769,7 +769,7 @@ allocate_filename_to_slot (const char * dirname,
{
const char * dir = NULL;
- if (dirs)
+ if (dirs != NULL)
dir = dirs[files[num].dir];
if (with_md5
@@ -787,7 +787,15 @@ allocate_filename_to_slot (const char * dirname,
/* If the filenames match, but the directory table entry was
empty, then fill it with the provided directory name. */
if (dir == NULL)
- dirs[files[num].dir] = xmemdup0 (dirname, strlen (dirname));
+ {
+ if (dirs == NULL)
+ {
+ dirs_allocated = files[num].dir + 32;
+ dirs = XCNEWVEC (char *, dirs_allocated);
+ }
+
+ dirs[files[num].dir] = xmemdup0 (dirname, strlen (dirname));
+ }
return TRUE;
}