Check input token length before copy

pull/2971/head
Max Vollmer 2020-01-29 15:04:26 +00:00
parent 26179cd4d2
commit 0d672efa90
1 changed files with 5 additions and 2 deletions

View File

@ -367,8 +367,11 @@ float ParseTokenAsFloat(const Token& t, const char*& err_out)
// first - next in the fbx token stream comes ',',
// which fast_atof could interpret as decimal point.
#define MAX_FLOAT_LENGTH 31
char temp[MAX_FLOAT_LENGTH + 1];
const size_t length = static_cast<size_t>(t.end()-t.begin());
if (length > MAX_FLOAT_LENGTH)
return 0.f;
char temp[MAX_FLOAT_LENGTH + 1];
std::copy(t.begin(), t.end(), temp);
temp[std::min(static_cast<size_t>(MAX_FLOAT_LENGTH),length)] = '\0';