Browse Source

Fixed bad parsing in BanDatabase.

pull/3/head
JustinAJ 10 years ago
parent
commit
a8d430942b
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 42
      RenX.Core/RenX_BanDatabase.cpp

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

42
RenX.Core/RenX_BanDatabase.cpp

@ -41,7 +41,7 @@ bool RenX::BanDatabase::load(const Jupiter::ReadableString &fname)
Jupiter::String key(32); Jupiter::String key(32);
Jupiter::String value(32); Jupiter::String value(32);
Entry *entry; Entry *entry;
char c; int c;
while (!feof(file)) while (!feof(file))
{ {
entry = new Entry(); entry = new Entry();
@ -56,41 +56,55 @@ bool RenX::BanDatabase::load(const Jupiter::ReadableString &fname)
delete entry; delete entry;
break; break;
} }
// load name
c = fgetc(file); c = fgetc(file);
while (c != '\n' && c != EOF) while (c != '\n' && c != '\0')
{
if (c == EOF)
{ {
if (c == '\0') fprintf(stderr, "ERROR: Unexpected EOF in %s at %lu", RenX::BanDatabase::filename.c_str(), ftell(file));
break;
}
playerName += c;
c = fgetc(file);
}
entry->name = playerName;
// load variable data
while (c == '\0')
{ {
key.truncate(key.size()); key.truncate(key.size());
value.truncate(value.size()); value.truncate(value.size());
// load key
c = fgetc(file); c = fgetc(file);
while (c != '\n' && c != EOF) while (c != '\0' && c != EOF)
{
while (c != '\0')
{ {
key += c; key += c;
c = fgetc(file); c = fgetc(file);
}
if (c == EOF) if (c == EOF)
{ {
fprintf(stderr, "ERROR: Unexpected EOF in %s at %lu", RenX::BanDatabase::filename.c_str(), ftell(file)); fprintf(stderr, "ERROR: Unexpected EOF in %s at %lu", RenX::BanDatabase::filename.c_str(), ftell(file));
break; break;
} }
}
// load value
c = fgetc(file); c = fgetc(file);
while (c != '\n' && c != EOF) while (c != '\n' && c != '\0' && c != EOF)
{ {
value += c; value += c;
c = fgetc(file); c = fgetc(file);
} }
entry->varData.set(key, value); if (c == EOF)
c = fgetc(file); {
} fprintf(stderr, "ERROR: Unexpected EOF in %s at %lu", RenX::BanDatabase::filename.c_str(), ftell(file));
break; break;
} }
playerName += c;
c = fgetc(file); entry->varData.set(key, value);
} }
entry->name = playerName;
entries.add(entry); entries.add(entry);
} }
fclose(file); fclose(file);

Loading…
Cancel
Save