1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 16:29:55 +00:00

Fix unintended sign extension in compressed BSA hash generation

Which, however, never happens with non-ASCII characters
This commit is contained in:
Alexei Kotov 2023-07-24 00:24:27 +03:00
parent a8119f3863
commit 353b06325e

View file

@ -470,7 +470,11 @@ namespace Bsa
return 0;
std::replace(str.begin(), str.end(), '/', '\\');
Misc::StringUtils::lowerCaseInPlace(str);
uint64_t result = str[len - 1] | (len >= 3 ? (str[len - 2] << 8) : 0) | (len << 16) | (str[0] << 24);
uint64_t result = str[len - 1];
if (len >= 3)
result |= str[len - 2] << 8;
result |= len << 16;
result |= static_cast<uint32_t>(str[0] << 24);
if (len >= 4)
{
uint32_t hash = 0;