dedicated: resolve out-of-bounds access during config parse

ASAN reports:

$GIT/Descent3/dedicated_server.cpp:350:24: runtime error: index 1024
out of bounds for type 'cvar_entry [36]'
$GIT/Descent3/dedicated_server.cpp:350:14: runtime error: load of
address 0x000001e677c0 with insufficient space for an object of type
'const char *'

This can happen if a line in the .cfg starts with a '#'.
This commit is contained in:
Jan Engelhardt 2024-09-09 09:49:31 +02:00
parent 6ad7a3d5cb
commit dfa0560aff

View File

@ -346,7 +346,8 @@ int LoadServerConfigFile() {
while (inf.ReadLine()) {
int cmd;
while ((cmd = inf.ParseLine(operand, INFFILE_LINELEN)) > INFFILE_ERROR) {
while ((cmd = inf.ParseLine(operand, INFFILE_LINELEN)) > INFFILE_ERROR &&
cmd != INFFILE_SYMBOL) {
SetCVar(CVars[cmd].varname, operand, true);
}
}