This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[tv] Patch: fix usage of ctype macros in gas/config/tc-m68k.c
- To: <binutils at sources dot redhat dot com>
- Subject: [tv] Patch: fix usage of ctype macros in gas/config/tc-m68k.c
- From: Todd Vierling <tv at wasabisystems dot com>
- Date: Fri, 2 Feb 2001 14:15:07 -0500 (Eastern Standard Time)
The following change is required to prevent improper memory accesses in
gas/config/tc-m68k.c.
The original code is truncating an "int" to a "char" to do lookup using
isupper() -- which will break starting at value 128, which truncates to -128
where char is signed, and ends up being sign-extended to an int -128. (This
is based on the standards in the Single Unix Specification v2, among others,
which define isupper() and toupper() as taking an "int" argument.)
I am the author of these changes, based on an earlier change in the NetBSD
source tree by ITOH Yasufumi <itohy@netbsd.org>. Note that I do not yet
have FSF copyright assignment forms on file, but the size of the changes are
rather small. I also hereby release this change to the public domain, if
that will assist in its integration.
=====
gas/ChangeLog entry:
2001-02-01 Todd Vierling <tv@wasabisystems.com>
* config/tc-m68k.c (md_begin): Don't truncate a byte value to a
(possibly signed) char and run it through isupper(); it may be
sign-extended to a negative integer value.
=====
Diff against binutils HEAD (may also be applied to 2.11 and/or 2.10
branches, if desired):
Index: gas/config/tc-m68k.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68k.c,v
retrieving revision 1.17
diff -u -r1.17 tc-m68k.c
--- gas/config/tc-m68k.c 2001/01/25 20:26:17 1.17
+++ gas/config/tc-m68k.c 2001/02/02 19:04:29
@@ -3768,7 +3768,6 @@
register struct m68k_incant *hack, *slak;
register const char *retval = 0; /* empty string, or error msg text */
register int i;
- register char c;
if (flag_mri)
{
@@ -3864,7 +3863,7 @@
}
for (i = 0; i < (int) sizeof (mklower_table); i++)
- mklower_table[i] = (isupper (c = (char) i)) ? tolower (c) : c;
+ mklower_table[i] = (char)((isupper (i)) ? tolower (i) : i);
for (i = 0; i < (int) sizeof (notend_table); i++)
{
--
-- Todd Vierling <tv@wasabisystems.com> * Wasabi NetBSD: Run with it.
-- NetBSD 1.5 now available on CD-ROM -- http://www.wasabisystems.com/