tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] patch for invalid array access in tcc.c


From: Brian Gough
Subject: [Tinycc-devel] patch for invalid array access in tcc.c
Date: Mon, 31 May 2004 15:22:32 +0100

Here is a patch to catch an invalid array access of isidnum_table[-1]
when tcc is called without arguments.

I picked this up with the -fbounds-checking extension to GCC
(http://gcc.gnu.org/extensions.html).

-- 
Brian Gough

Network Theory Ltd,
Publishing Free Software Manuals --- http://www.network-theory.co.uk/

$ pwd
/home/bjg/ftp/tcc-0.9.20
$ make CC="/opt/gcc-3.3.3bc/bin/gcc" CFLAGS="-fbounds-checking -g"
$ ./tcc
Bounds Checking GCC v gcc-3.3.3-3.2 Copyright (C) 1995 Richard W.M. Jones
Bounds Checking comes with ABSOLUTELY NO WARRANTY. For details see file
`COPYING' that should have come with the source to this program.
Bounds Checking is free software, and you are welcome to redistribute it
under certain conditions. See the file `COPYING' for details.
For more information, set GCC_BOUNDS_OPTS to `-help'
tcc.c:3377:Bounds error: array reference (-1) outside bounds of the array.
tcc.c:3377:  Pointer value: 0x80be77f
tcc.c:3377:  Object `isidnum_table':
tcc.c:3377:    Address in memory:    0x80be780 .. 0x80be87f
tcc.c:3377:    Size:                 256 bytes
tcc.c:3377:    Element size:         1 bytes
tcc.c:3377:    Number of elements:   256
tcc.c:3377:    Created at:           tcc.c, line 325
tcc.c:3377:    Storage class:        static
Aborted

----------------------------------------------------------------------
RCS file: tcc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- tcc.c       2004/05/31 13:54:48     1.2
+++ tcc.c       2004/05/31 13:55:03     1.3
@@ -3374,7 +3374,7 @@
             p--;
             PEEKC(c, p);
         parse_ident_slow:
-            while (isidnum_table[c]) {
+            while (c > 0 && isidnum_table[c]) {
                 cstr_ccat(&tokcstr, c);
                 PEEKC(c, p);
             }

----------------------------------------------------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]