This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
mips assembler: fix memory corruption problem
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: 18 Nov 2002 18:37:28 -0200
- Subject: mips assembler: fix memory corruption problem
- Organization: GCC Team, Red Hat
I noticed that some object files got oddly-named sections in object
files while trying to fix bootstrap problems on IRIX. It turned out
the section names pointed into input buffers, that were overwritten
before the end of the assembly. Oops. This patch fixes the problem,
and also makes sure we can't possibly access the input buffer past its
end, which might happen in case the section name was actually the last
thing in the buffer. Ok to install?
Index: gas/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* config/tc-mips.c (s_change_section): Make sure input buffer
is not accessed past the end. Don't hand
obj_elf_change_section a pointer into the input buffer.
Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.177
diff -u -p -r1.177 tc-mips.c
--- gas/config/tc-mips.c 7 Nov 2002 02:29:32 -0000 1.177
+++ gas/config/tc-mips.c 18 Nov 2002 20:31:40 -0000
@@ -11657,7 +11657,8 @@ s_change_section (ignore)
section_name = input_line_pointer;
c = get_symbol_end ();
- next_c = *(input_line_pointer + 1);
+ if (c)
+ next_c = *(input_line_pointer + 1);
/* Do we have .section Name<,"flags">? */
if (c != ',' || (c == ',' && next_c == '"'))
@@ -11688,8 +11689,13 @@ s_change_section (ignore)
else
section_alignment = 0;
+ section_name = xstrdup (section_name);
+
obj_elf_change_section (section_name, section_type, section_flag,
section_entry_size, 0, 0, 0);
+
+ if (now_seg->name != section_name)
+ free (section_name);
#endif /* OBJ_ELF */
}
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer