mirror of https://github.com/golang/go.git
cmd/cc: grow some global arrays
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
This commit is contained in:
parent
91bdbf591f
commit
9984a5bca4
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ Node* nodmmv;
|
|||
|
||||
Node* nodvasop;
|
||||
|
||||
char etconv[NTYPE]; /* for _vasop */
|
||||
char etconv[NALLTYPES]; /* for _vasop */
|
||||
Init initetconv[] =
|
||||
{
|
||||
TCHAR, 1, 0,
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue