mirror of
https://github.com/accelerator74/Cleaner.git
synced 2025-12-06 18:18:27 +00:00
Read file line into temp string before using.
This commit is contained in:
parent
a8148454bb
commit
419ff8d178
@ -88,25 +88,20 @@ bool Cleaner::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
while (!feof(file))
|
||||
{
|
||||
// we don't need to have 256 chars to work with here as most strings are far smaller than that
|
||||
g_szStrings[g_iStrings] = new char[128];
|
||||
|
||||
// fgets stops at n - 1 aka 127
|
||||
if (fgets(g_szStrings[g_iStrings], 128, file) != NULL)
|
||||
char* temp = new char[128];
|
||||
if (fgets(temp, 128, file) != NULL)
|
||||
{
|
||||
// make things a little easier on ourselves
|
||||
std::string thisstring = g_szStrings[g_iStrings];
|
||||
std::string thisstring = string(temp);
|
||||
|
||||
// significantly more robust way of stripping evil chars from our string so we don't crash
|
||||
// when we try to strip them. this includes newlines, control chars, non ascii unicde, etc.
|
||||
stripBadChars(thisstring);
|
||||
|
||||
// copy our std::string back to char*
|
||||
// Disgusting.
|
||||
char* c_thisstring = &thisstring[0];
|
||||
|
||||
int len = strlen(c_thisstring);
|
||||
|
||||
// don't strip tiny (including 0 len or less) strings
|
||||
if (len <= 1)
|
||||
if (thisstring.length() <= 1)
|
||||
{
|
||||
rootconsole->ConsolePrint("[CLEANER] Not stripping string on -> L%i with 1 or less length! Length: %i", g_iStrings+1, strlen(c_thisstring));
|
||||
}
|
||||
@ -114,11 +109,12 @@ bool Cleaner::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
{
|
||||
rootconsole->ConsolePrint("[CLEANER] Stripping string on -> L%i: \"%s\" - length: %i", g_iStrings+1, c_thisstring, strlen(c_thisstring));
|
||||
}
|
||||
|
||||
strcpy(g_szStrings[g_iStrings], c_thisstring);
|
||||
g_szStrings[g_iStrings] = new char[thisstring.length()];
|
||||
strcpy(g_szStrings[g_iStrings], c_thisstring.c_str());
|
||||
|
||||
++g_iStrings;
|
||||
}
|
||||
delete [] temp;
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user