mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-25 11:21:58 +01:00
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:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user