Core/Misc: Throw an exception if client sends invalid float/double data

Throw a ByteBufferException if client sends 1.#INF0000, 1.#QNAN000, 1.#IND0000 or other invalid float/double values.
Handle this invalid values in StaticMapTree::isInLineOfSight() to avoid triggering an assert.
Fixes #12126
This commit is contained in:
jackpoz
2014-05-25 14:42:22 +02:00
parent 01b33a6772
commit 5e66253de2
2 changed files with 5 additions and 2 deletions

View File

@@ -157,8 +157,7 @@ namespace VMAP
{
float maxDist = (pos2 - pos1).magnitude();
// return false if distance is over max float, in case of cheater teleporting to the end of the universe
if (maxDist == std::numeric_limits<float>::max() ||
maxDist == std::numeric_limits<float>::infinity())
if (maxDist == std::numeric_limits<float>::max() || !isfinite(maxDist))
return false;
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too

View File

@@ -241,12 +241,16 @@ class ByteBuffer
ByteBuffer &operator>>(float &value)
{
value = read<float>();
if (!isfinite(value))
throw ByteBufferException();
return *this;
}
ByteBuffer &operator>>(double &value)
{
value = read<double>();
if (!isfinite(value))
throw ByteBufferException();
return *this;
}