From: "H. J. Lu" <hjl@lucon.org>
To: Nick Clifton <nickc@redhat.com>
Cc: binutils@sources.redhat.com, jbeulich@novell.com
Subject: Re: PATCH: Fix buffer overflow in gas
Date: Tue, 02 May 2006 14:20:00 -0000 [thread overview]
Message-ID: <20060502142031.GA10660@lucon.org> (raw)
In-Reply-To: <20060502133130.GB10201@lucon.org>
On Tue, May 02, 2006 at 06:31:30AM -0700, H. J. Lu wrote:
> On Tue, May 02, 2006 at 10:47:27AM +0100, Nick Clifton wrote:
> > Hi H. J.
> >
> > >There are some potential buffer overflows in gas. 8byte isn't enough
> > >to hold a negative byte. This patch fixes them. Also we should use
> > >snprintf instead of sprintf.
> >
> > Did you test this patch ? if so, please could you say how.
>
> You can put some none ascii char in assembly code.
>
> >
> > >2006-05-01 H.J. Lu <hongjiu.lu@intel.com>
> > >
> > > * config/tc-i386.c (output_invalid_buf): Change size to 16.
> > > * config/tc-tic30.c (output_invalid_buf): Likewise.
> > >
> > > * config/tc-i386.c (output_invalid): Use snprintf instead of
> > > sprintf.
> > > * config/tc-ia64.c (declare_register_set): Likewise.
> > > (emit_one_bundle): Likewise.
> > > (check_dependencies): Likewise.
> > > * config/tc-tic30.c (output_invalid): Likewise.
> >
> > Assuming that you have tested the targets involved and that there were
> > no regressions then this patch is approved.
>
> Done.
>
Jan suggested we should cast int to unsigned char.
foo.s:20: Error: invalid character (0xd6) in mnemonic
is better than
foo.s:20: Error: invalid character (0xfffffffd6) in mnemonic
I will check it in.
H.J.
---
2006-05-02 H.J. Lu <hongjiu.lu@intel.com>
Jan Beulich <jbeulich@novell.com>
* config/tc-i386.c (output_invalid_buf): Change size for
unsigned char.
* config/tc-tic30.c (output_invalid_buf): Likewise.
* config/tc-i386.c (output_invalid): Cast none-ascii char to
unsigned char.
* config/tc-tic30.c (output_invalid): Likewise.
--- gas/config/tc-i386.c.buf 2006-05-02 06:50:00.000000000 -0700
+++ gas/config/tc-i386.c 2006-05-02 07:12:03.000000000 -0700
@@ -5251,7 +5251,7 @@ md_atof (type, litP, sizeP)
return 0;
}
\f
-static char output_invalid_buf[16];
+static char output_invalid_buf[sizeof (unsigned char) * 2 + 6];
static char *
output_invalid (c)
@@ -5262,7 +5262,7 @@ output_invalid (c)
"'%c'", c);
else
snprintf (output_invalid_buf, sizeof (output_invalid_buf),
- "(0x%x)", (unsigned) c);
+ "(0x%x)", (unsigned char) c);
return output_invalid_buf;
}
--- gas/config/tc-tic30.c.buf 2006-05-02 06:50:00.000000000 -0700
+++ gas/config/tc-tic30.c 2006-05-02 07:12:11.000000000 -0700
@@ -273,7 +273,7 @@ struct tic30_insn
struct tic30_insn insn;
static int found_parallel_insn;
-static char output_invalid_buf[16];
+static char output_invalid_buf[sizeof (unsigned char) * 2 + 6];
static char *
output_invalid (char c)
@@ -283,7 +283,7 @@ output_invalid (char c)
"'%c'", c);
else
snprintf (output_invalid_buf, sizeof (output_invalid_buf),
- "(0x%x)", (unsigned) c);
+ "(0x%x)", (unsigned char) c);
return output_invalid_buf;
}
2006-05-02 H.J. Lu <hongjiu.lu@intel.com>
* config/tc-i386.c (output_invalid_buf): Change size for
unsigned char.
* config/tc-tic30.c (output_invalid_buf): Likewise.
* config/tc-i386.c (output_invalid): Cast none-ascii char to
unsigned char.
* config/tc-tic30.c (output_invalid): Likewise.
--- gas/config/tc-i386.c.buf 2006-05-02 06:50:00.000000000 -0700
+++ gas/config/tc-i386.c 2006-05-02 07:12:03.000000000 -0700
@@ -5251,7 +5251,7 @@ md_atof (type, litP, sizeP)
return 0;
}
\f
-static char output_invalid_buf[16];
+static char output_invalid_buf[sizeof (unsigned char) * 2 + 6];
static char *
output_invalid (c)
@@ -5262,7 +5262,7 @@ output_invalid (c)
"'%c'", c);
else
snprintf (output_invalid_buf, sizeof (output_invalid_buf),
- "(0x%x)", (unsigned) c);
+ "(0x%x)", (unsigned char) c);
return output_invalid_buf;
}
--- gas/config/tc-tic30.c.buf 2006-05-02 06:50:00.000000000 -0700
+++ gas/config/tc-tic30.c 2006-05-02 07:12:11.000000000 -0700
@@ -273,7 +273,7 @@ struct tic30_insn
struct tic30_insn insn;
static int found_parallel_insn;
-static char output_invalid_buf[16];
+static char output_invalid_buf[sizeof (unsigned char) * 2 + 6];
static char *
output_invalid (char c)
@@ -283,7 +283,7 @@ output_invalid (char c)
"'%c'", c);
else
snprintf (output_invalid_buf, sizeof (output_invalid_buf),
- "(0x%x)", (unsigned) c);
+ "(0x%x)", (unsigned char) c);
return output_invalid_buf;
}
next prev parent reply other threads:[~2006-05-02 14:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-01 18:40 H. J. Lu
2006-05-02 9:48 ` Nick Clifton
2006-05-02 13:31 ` H. J. Lu
2006-05-02 14:20 ` H. J. Lu [this message]
2006-05-02 14:35 ` Jan Beulich
2006-05-02 14:58 ` H. J. Lu
2006-05-02 16:53 ` Andreas Schwab
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=20060502142031.GA10660@lucon.org \
--to=hjl@lucon.org \
--cc=binutils@sources.redhat.com \
--cc=jbeulich@novell.com \
--cc=nickc@redhat.com \
/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).