mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
fix(Core/SQLField): Fix heap-buffer-overflow issue when interacting with mysql field value. (#21393)
This commit is contained in:
committed by
GitHub
parent
c2986977d9
commit
07cb5c880c
@@ -212,7 +212,7 @@ T Field::GetData() const
|
|||||||
if (data.raw)
|
if (data.raw)
|
||||||
result = *reinterpret_cast<T const*>(data.value);
|
result = *reinterpret_cast<T const*>(data.value);
|
||||||
else
|
else
|
||||||
result = Acore::StringTo<T>(data.value);
|
result = Acore::StringTo<T>(std::string_view(data.value, data.length));
|
||||||
|
|
||||||
// Correct double fields... this undefined behavior :/
|
// Correct double fields... this undefined behavior :/
|
||||||
if constexpr (std::is_same_v<T, double>)
|
if constexpr (std::is_same_v<T, double>)
|
||||||
@@ -220,7 +220,7 @@ T Field::GetData() const
|
|||||||
if (data.raw && !IsType(DatabaseFieldTypes::Decimal))
|
if (data.raw && !IsType(DatabaseFieldTypes::Decimal))
|
||||||
result = *reinterpret_cast<double const*>(data.value);
|
result = *reinterpret_cast<double const*>(data.value);
|
||||||
else
|
else
|
||||||
result = Acore::StringTo<float>(data.value);
|
result = Acore::StringTo<float>(std::string_view(data.value, data.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check -1 for *_dbc db tables
|
// Check -1 for *_dbc db tables
|
||||||
@@ -230,7 +230,7 @@ T Field::GetData() const
|
|||||||
|
|
||||||
if (!tableName.empty() && tableName.size() > 4)
|
if (!tableName.empty() && tableName.size() > 4)
|
||||||
{
|
{
|
||||||
auto signedResult = Acore::StringTo<int32>(data.value);
|
auto signedResult = Acore::StringTo<int32>(std::string_view(data.value, data.length));
|
||||||
|
|
||||||
if (signedResult && !result && tableName.substr(tableName.length() - 4) == "_dbc")
|
if (signedResult && !result && tableName.substr(tableName.length() - 4) == "_dbc")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user