Use strncat instead of strcat to prevent some buffer overflows

This commit is contained in:
Glenn Smith 2018-03-06 00:48:44 -05:00
parent bf408235a8
commit 1728fe39ad
32 changed files with 147 additions and 134 deletions

View file

@ -908,7 +908,7 @@ ConsoleFunction(echoThru, const char*, 2, 0, "(string passthru, string text...)"
char *ret = Con::getReturnBuffer(len + 1);
ret[0] = 0;
for(i = 2; i < argc; i++)
dStrcat(ret, argv[i]);
dStrcat(ret, argv[i], len);
Con::printf("%s -- [%s]", ret, argv[1].getStringValue());
ret[0] = 0;
@ -928,7 +928,7 @@ ConsoleFunction(warnThru, const char*, 2, 0, "(string passthru, string text...)"
char *ret = Con::getReturnBuffer(len + 1);
ret[0] = 0;
for(i = 2; i < argc; i++)
dStrcat(ret, argv[i]);
dStrcat(ret, argv[i], len);
Con::warnf("%s -- [%s]", ret, argv[1].getStringValue());
ret[0] = 0;
@ -948,7 +948,7 @@ ConsoleFunction(errorThru, const char*, 2, 0, "(string passthru, string text...)
char *ret = Con::getReturnBuffer(len + 1);
ret[0] = 0;
for(i = 2; i < argc; i++)
dStrcat(ret, argv[i]);
dStrcat(ret, argv[i], len);
Con::errorf("%s -- [%s]", ret, argv[1].getStringValue());
ret[0] = 0;

View file

@ -227,7 +227,7 @@ char* afxRPGMagicSpellData::formatDesc(char* buffer, int len) const
{
dStrcpy(target_str, _afxRPGMagicSpell_TargetType::_sEnumTable[i].mName);
if (spell_target != TARGET_FREE && target_optional)
dStrcat(target_str, " (opt)");
dStrcat(target_str, " (opt)", 32);
}
break;
}