Fix unchecked buffer size issues in l_script.c and l_precomp.c

Found by Coverity.
This commit is contained in:
Zack Middleton 2014-05-25 17:02:33 -05:00
parent 078d004dc2
commit eea9fbdb61
2 changed files with 16 additions and 9 deletions

View file

@ -956,6 +956,7 @@ int PS_ExpectTokenType(script_t *script, int type, int subtype, token_t *token)
if (token->type != type)
{
strcpy(str, "");
if (type == TT_STRING) strcpy(str, "string");
if (type == TT_LITERAL) strcpy(str, "literal");
if (type == TT_NUMBER) strcpy(str, "number");
@ -968,6 +969,7 @@ int PS_ExpectTokenType(script_t *script, int type, int subtype, token_t *token)
{
if ((token->subtype & subtype) != subtype)
{
strcpy(str, "");
if (subtype & TT_DECIMAL) strcpy(str, "decimal");
if (subtype & TT_HEX) strcpy(str, "hex");
if (subtype & TT_OCTAL) strcpy(str, "octal");
@ -1350,7 +1352,7 @@ script_t *LoadScriptFile(const char *filename)
buffer = GetClearedMemory(sizeof(script_t) + length + 1);
script = (script_t *) buffer;
Com_Memset(script, 0, sizeof(script_t));
strcpy(script->filename, filename);
Q_strncpyz(script->filename, filename, sizeof(script->filename));
script->buffer = (char *) buffer + sizeof(script_t);
script->buffer[length] = 0;
script->length = length;
@ -1396,7 +1398,7 @@ script_t *LoadScriptMemory(char *ptr, int length, char *name)
buffer = GetClearedMemory(sizeof(script_t) + length + 1);
script = (script_t *) buffer;
Com_Memset(script, 0, sizeof(script_t));
strcpy(script->filename, name);
Q_strncpyz(script->filename, name, sizeof(script->filename));
script->buffer = (char *) buffer + sizeof(script_t);
script->buffer[length] = 0;
script->length = length;