Merge pull request #2971 from ms-maxvollmer/FBXParser_check_inputlength_fix
Check input token length before copypull/2973/head
commit
aed762acd7
|
@ -367,9 +367,13 @@ float ParseTokenAsFloat(const Token& t, const char*& err_out)
|
||||||
// first - next in the fbx token stream comes ',',
|
// first - next in the fbx token stream comes ',',
|
||||||
// which fast_atof could interpret as decimal point.
|
// which fast_atof could interpret as decimal point.
|
||||||
#define MAX_FLOAT_LENGTH 31
|
#define MAX_FLOAT_LENGTH 31
|
||||||
char temp[MAX_FLOAT_LENGTH + 1];
|
|
||||||
const size_t length = static_cast<size_t>(t.end()-t.begin());
|
const size_t length = static_cast<size_t>(t.end()-t.begin());
|
||||||
std::copy(t.begin(),t.end(),temp);
|
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';
|
temp[std::min(static_cast<size_t>(MAX_FLOAT_LENGTH),length)] = '\0';
|
||||||
|
|
||||||
return fast_atof(temp);
|
return fast_atof(temp);
|
||||||
|
|
Loading…
Reference in New Issue