]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cc: grow some global arrays
authorRuss Cox <rsc@golang.org>
Fri, 24 Feb 2012 03:45:55 +0000 (22:45 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 24 Feb 2012 03:45:55 +0000 (22:45 -0500)
Avoids global array buffer overflows if they are
indexed using some of the values between NTYPE
and NALLTYPE.  It is entirely likely that not all of these
are necessary, but this is the C compiler and not worth
worrying much about.  This change takes up only a
few more bytes of memory and makes the behavior
deterministic.

Fixes #3078.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5693052

src/cmd/cc/cc.h
src/cmd/cc/com64.c
src/cmd/cc/funct.c
src/cmd/cc/sub.c

index f4632364cf0ec66e262e358137382c6b19e1ef52..4c527a2b3d4410c6eb4eb1d437dbc1f2c17102b2 100644 (file)
@@ -517,8 +517,8 @@ EXTERN      int     thechar;
 EXTERN char*   thestring;
 EXTERN Type*   thisfn;
 EXTERN int32   thunk;
-EXTERN Type*   types[NTYPE];
-EXTERN Type*   fntypes[NTYPE];
+EXTERN Type*   types[NALLTYPES];
+EXTERN Type*   fntypes[NALLTYPES];
 EXTERN Node*   initlist;
 EXTERN Term    term[NTERM];
 EXTERN int     nterm;
index fb7a3f750e77705630c587b1757de01558535ad7..f46fedc16aaf2a14d2f3e66fd9ed3dfe78623669 100644 (file)
@@ -96,7 +96,7 @@ Node* nodmmv;
 
 Node*  nodvasop;
 
-char   etconv[NTYPE];  /* for _vasop */
+char   etconv[NALLTYPES];      /* for _vasop */
 Init   initetconv[] =
 {
        TCHAR,          1,      0,
index 99477b2b2386447b831aa30e6c08ed7d1d3c1472..05715198715bd2e754e919d8fa7e73bb241477d7 100644 (file)
@@ -46,7 +46,7 @@ struct        Gtab
 };
 
 Ftab   ftabinit[OEND];
-Gtab   gtabinit[NTYPE];
+Gtab   gtabinit[NALLTYPES];
 
 int
 isfunct(Node *n)
@@ -350,7 +350,7 @@ bad:
        diag(Z, "dclfunct bad %T %s\n", t, s->name);
 }
 
-Gtab   gtabinit[NTYPE] =
+Gtab   gtabinit[NALLTYPES] =
 {
        TCHAR,          "c",
        TUCHAR,         "uc",
index 98e9f5a4b43fa50ce572e9fcda0ff813c7d85adb..72d671b2f586570b74624a387b1c7ecbfe75e6e0 100644 (file)
@@ -1538,92 +1538,92 @@ uchar   logrel[12] =
        OEQ, ONE, OLS, OLS, OLO, OLO, OHS, OHS, OHI, OHI,
 };
 
-uchar  typei[NTYPE];
+uchar  typei[NALLTYPES];
 int    typeiinit[] =
 {
        TCHAR, TUCHAR, TSHORT, TUSHORT, TINT, TUINT, TLONG, TULONG, TVLONG, TUVLONG, -1,
 };
-uchar  typeu[NTYPE];
+uchar  typeu[NALLTYPES];
 int    typeuinit[] =
 {
        TUCHAR, TUSHORT, TUINT, TULONG, TUVLONG, TIND, -1,
 };
 
-uchar  typesuv[NTYPE];
+uchar  typesuv[NALLTYPES];
 int    typesuvinit[] =
 {
        TVLONG, TUVLONG, TSTRUCT, TUNION, -1,
 };
 
-uchar  typeilp[NTYPE];
+uchar  typeilp[NALLTYPES];
 int    typeilpinit[] =
 {
        TINT, TUINT, TLONG, TULONG, TIND, -1
 };
 
-uchar  typechl[NTYPE];
-uchar  typechlv[NTYPE];
-uchar  typechlvp[NTYPE];
+uchar  typechl[NALLTYPES];
+uchar  typechlv[NALLTYPES];
+uchar  typechlvp[NALLTYPES];
 int    typechlinit[] =
 {
        TCHAR, TUCHAR, TSHORT, TUSHORT, TINT, TUINT, TLONG, TULONG, -1,
 };
 
-uchar  typechlp[NTYPE];
+uchar  typechlp[NALLTYPES];
 int    typechlpinit[] =
 {
        TCHAR, TUCHAR, TSHORT, TUSHORT, TINT, TUINT, TLONG, TULONG, TIND, -1,
 };
 
-uchar  typechlpfd[NTYPE];
+uchar  typechlpfd[NALLTYPES];
 int    typechlpfdinit[] =
 {
        TCHAR, TUCHAR, TSHORT, TUSHORT, TINT, TUINT, TLONG, TULONG, TFLOAT, TDOUBLE, TIND, -1,
 };
 
-uchar  typec[NTYPE];
+uchar  typec[NALLTYPES];
 int    typecinit[] =
 {
        TCHAR, TUCHAR, -1
 };
 
-uchar  typeh[NTYPE];
+uchar  typeh[NALLTYPES];
 int    typehinit[] =
 {
        TSHORT, TUSHORT, -1,
 };
 
-uchar  typeil[NTYPE];
+uchar  typeil[NALLTYPES];
 int    typeilinit[] =
 {
        TINT, TUINT, TLONG, TULONG, -1,
 };
 
-uchar  typev[NTYPE];
+uchar  typev[NALLTYPES];
 int    typevinit[] =
 {
        TVLONG, TUVLONG, -1,
 };
 
-uchar  typefd[NTYPE];
+uchar  typefd[NALLTYPES];
 int    typefdinit[] =
 {
        TFLOAT, TDOUBLE, -1,
 };
 
-uchar  typeaf[NTYPE];
+uchar  typeaf[NALLTYPES];
 int    typeafinit[] =
 {
        TFUNC, TARRAY, -1,
 };
 
-uchar  typesu[NTYPE];
+uchar  typesu[NALLTYPES];
 int    typesuinit[] =
 {
        TSTRUCT, TUNION, -1,
 };
 
-int32  tasign[NTYPE];
+int32  tasign[NALLTYPES];
 Init   tasigninit[] =
 {
        TCHAR,          BNUMBER,        0,
@@ -1644,7 +1644,7 @@ Init      tasigninit[] =
        -1,             0,              0,
 };
 
-int32  tasadd[NTYPE];
+int32  tasadd[NALLTYPES];
 Init   tasaddinit[] =
 {
        TCHAR,          BNUMBER,        0,
@@ -1663,7 +1663,7 @@ Init      tasaddinit[] =
        -1,             0,              0,
 };
 
-int32  tcast[NTYPE];
+int32  tcast[NALLTYPES];
 Init   tcastinit[] =
 {
        TCHAR,          BNUMBER|BIND|BVOID,     0,
@@ -1685,7 +1685,7 @@ Init      tcastinit[] =
        -1,             0,                      0,
 };
 
-int32  tadd[NTYPE];
+int32  tadd[NALLTYPES];
 Init   taddinit[] =
 {
        TCHAR,          BNUMBER|BIND,   0,
@@ -1704,7 +1704,7 @@ Init      taddinit[] =
        -1,             0,              0,
 };
 
-int32  tsub[NTYPE];
+int32  tsub[NALLTYPES];
 Init   tsubinit[] =
 {
        TCHAR,          BNUMBER,        0,
@@ -1723,7 +1723,7 @@ Init      tsubinit[] =
        -1,             0,              0,
 };
 
-int32  tmul[NTYPE];
+int32  tmul[NALLTYPES];
 Init   tmulinit[] =
 {
        TCHAR,          BNUMBER,        0,
@@ -1741,7 +1741,7 @@ Init      tmulinit[] =
        -1,             0,              0,
 };
 
-int32  tand[NTYPE];
+int32  tand[NALLTYPES];
 Init   tandinit[] =
 {
        TCHAR,          BINTEGER,       0,
@@ -1757,7 +1757,7 @@ Init      tandinit[] =
        -1,             0,              0,
 };
 
-int32  trel[NTYPE];
+int32  trel[NALLTYPES];
 Init   trelinit[] =
 {
        TCHAR,          BNUMBER,        0,