public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: Fix TIC54X buffer overruns
Date: Mon, 16 Jun 2014 03:43:00 -0000	[thread overview]
Message-ID: <20140616034303.GE3462@bubble.grove.modra.org> (raw)
In-Reply-To: <20140614004846.GI7683@bubble.grove.modra.org>

MALLOC_PERTURB_=1 results in "FAIL: c54x macros".

	* config/tc-tic54x.c (tic54x_mlib): Don't write garbage past
	end of archive to temp file.
	(tic54x_start_line_hook): Start scan for parallel on next line,
	not one char into next line (which may overrun the buffer).

diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c
index bba743c..c997297 100644
--- a/gas/config/tc-tic54x.c
+++ b/gas/config/tc-tic54x.c
@@ -2368,13 +2368,13 @@ tic54x_mlib (int ignore ATTRIBUTE_UNUSED)
       FILE *ftmp;
 
       /* We're not sure how big it is, but it will be smaller than "size".  */
-      bfd_bread (buf, size, mbfd);
+      size = bfd_bread (buf, size, mbfd);
 
       /* Write to a temporary file, then use s_include to include it
 	 a bit of a hack.  */
       ftmp = fopen (fname, "w+b");
       fwrite ((void *) buf, size, 1, ftmp);
-      if (buf[size - 1] != '\n')
+      if (size == 0 || buf[size - 1] != '\n')
 	fwrite ("\n", 1, 1, ftmp);
       fclose (ftmp);
       free (buf);
@@ -4777,7 +4777,7 @@ tic54x_start_line_hook (void)
   line[endp - input_line_pointer] = 0;
 
   /* Scan ahead for parallel insns.  */
-  parallel_on_next_line_hint = next_line_shows_parallel (endp + 1);
+  parallel_on_next_line_hint = next_line_shows_parallel (endp);
 
   /* If within a macro, first process forced replacements.  */
   if (macro_level > 0)

-- 
Alan Modra
Australia Development Lab, IBM

  parent reply	other threads:[~2014-06-16  3:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-14  0:48 testsuite results with MALLOC_PERTURB_=1 Alan Modra
2014-06-16  3:37 ` Fix uninitialised CRIS insn Alan Modra
2014-06-16  5:12   ` Hans-Peter Nilsson
2014-06-16  7:40     ` Alan Modra
2014-06-16 13:32       ` Hans-Peter Nilsson
2014-06-16 23:04         ` Hans-Peter Nilsson
2014-06-16  3:39 ` Fix uninitialised ARM data Alan Modra
2014-06-16  3:40 ` Fix uninitialised VAX .got and .got.plt section Alan Modra
2014-06-16  3:42 ` Fix uninitialised VAX insn Alan Modra
2014-06-16  3:43 ` Alan Modra [this message]
2014-06-16  3:44 ` Fix unintitialised TIC6X data Alan Modra
2014-06-16  3:45 ` Report an error on x86 pcrel BFD_RELOC_SIZE64 Alan Modra
2014-06-16  3:46 ` Don't leave DLX the_insn uninitialised Alan Modra
2014-06-16  3:50 ` Run write_object_file after errors Alan Modra
2014-06-27  3:21   ` Alan Modra
2014-06-27  8:01     ` Tristan Gingold

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=20140616034303.GE3462@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@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).