1
0
Fork 0

Fix #6564: enforce types of arguments for station name strings (#7419)

pull/7422/head
glx22 2019-03-26 22:50:56 +01:00 committed by GitHub
parent a065d4623e
commit 427d9d483f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -76,7 +76,10 @@ int64 StringParameters::GetInt64(WChar type)
return 0; return 0;
} }
if (this->type != NULL) { if (this->type != NULL) {
assert(this->type[this->offset] == 0 || this->type[this->offset] == type); if (this->type[this->offset] != 0 && this->type[this->offset] != type) {
DEBUG(misc, 0, "Trying to read string parameter with wrong type");
return 0;
}
this->type[this->offset] = type; this->type[this->offset] = type;
} }
return this->data[this->offset++]; return this->data[this->offset++];
@ -1415,8 +1418,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
} }
} }
int64 args_array[] = {STR_TOWN_NAME, st->town->index, st->index}; uint64 args_array[] = {STR_TOWN_NAME, st->town->index, st->index};
StringParameters tmp_params(args_array); WChar types_array[] = {0, SCC_TOWN_NAME, SCC_NUM};
StringParameters tmp_params(args_array, 3, types_array);
buff = GetStringWithArgs(buff, str, &tmp_params, last); buff = GetStringWithArgs(buff, str, &tmp_params, last);
} }
break; break;