Fixed stack overflow in CPPextension function. An arbitrary size buffer was being used for extension name. Changed it to use MAX_SYMBOL_NAME_LEN.
- Also formalized the values for MAX_SYMBOL_NAME_LEN and MAX_STRING_LEN. They were being used as if there was a confusion whether it included the NULL terminator or not.
- Fixed some minor issues with code releated to the usage of MAX_SYMBOL_NAME_LEN and MAX_STRING_LEN.
BUG=59625 (crbug.com)
Review URL: http://codereview.appspot.com/2585042
git-svn-id: https://angleproject.googlecode.com/svn/trunk@464 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/preprocessor/cpp.c b/src/compiler/preprocessor/cpp.c
index f15c56d..e73e314 100644
--- a/src/compiler/preprocessor/cpp.c
+++ b/src/compiler/preprocessor/cpp.c
@@ -670,7 +670,7 @@
{
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- char extensionName[80];
+ char extensionName[MAX_SYMBOL_NAME_LEN + 1];
if(token=='\n'){
DecLineNumber();
@@ -682,7 +682,8 @@
if (token != CPP_IDENTIFIER)
CPPErrorToInfoLog("#extension");
- strcpy(extensionName, GetAtomString(atable, yylvalpp->sc_ident));
+ strncpy(extensionName, GetAtomString(atable, yylvalpp->sc_ident), MAX_SYMBOL_NAME_LEN);
+ extensionName[MAX_SYMBOL_NAME_LEN] = '\0';
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != ':') {