mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 01:23:51 +00:00
fix: tolower/toupper UB on signed char at 10 remaining call sites
Final sweep across mpq_manager, application, auth_screen, wmo_renderer, character_renderer, and terrain_manager. All now use the unsigned char cast pattern. No remaining bare ::tolower/::toupper or std::tolower(c) calls on signed char in the codebase.
This commit is contained in:
parent
34e384e1b2
commit
f02be1ffac
6 changed files with 13 additions and 11 deletions
|
|
@ -5606,7 +5606,7 @@ void Application::buildCreatureDisplayLookups() {
|
|||
|
||||
// Resolve gryphon/wyvern display IDs by exact model path so taxi mounts have textures.
|
||||
auto toLower = [](std::string s) {
|
||||
for (char& c : s) c = static_cast<char>(::tolower(c));
|
||||
for (char& c : s) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
return s;
|
||||
};
|
||||
auto normalizePath = [&](const std::string& p) {
|
||||
|
|
@ -8251,7 +8251,7 @@ void Application::spawnOnlineGameObject(uint64_t guid, uint32_t entry, uint32_t
|
|||
if (basePath.size() > 4) {
|
||||
extension = basePath.substr(basePath.size() - 4);
|
||||
std::string extLower = extension;
|
||||
for (char& c : extLower) c = static_cast<char>(std::tolower(c));
|
||||
for (char& c : extLower) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
if (extLower == ".wmo") {
|
||||
basePath = basePath.substr(0, basePath.size() - 4);
|
||||
}
|
||||
|
|
@ -8423,7 +8423,8 @@ void Application::spawnOnlineGameObject(uint64_t guid, uint32_t entry, uint32_t
|
|||
// Freeze animation for static gameobjects, but let portals/effects/transports animate
|
||||
bool isTransportGO = gameHandler && gameHandler->isTransportGuid(guid);
|
||||
std::string lowerPath = modelPath;
|
||||
std::transform(lowerPath.begin(), lowerPath.end(), lowerPath.begin(), ::tolower);
|
||||
std::transform(lowerPath.begin(), lowerPath.end(), lowerPath.begin(),
|
||||
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
||||
bool isAnimatedEffect = (lowerPath.find("instanceportal") != std::string::npos ||
|
||||
lowerPath.find("instancenewportal") != std::string::npos ||
|
||||
lowerPath.find("portalfx") != std::string::npos ||
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ std::vector<uint8_t> MPQManager::readFile(const std::string& filename) const {
|
|||
std::string entryName = entry.path().filename().string();
|
||||
// Case-insensitive comparison
|
||||
if (std::equal(comp.begin(), comp.end(), entryName.begin(), entryName.end(),
|
||||
[](char a, char b) { return std::tolower(a) == std::tolower(b); })) {
|
||||
[](unsigned char a, unsigned char b) { return std::tolower(a) == std::tolower(b); })) {
|
||||
searchPath = entry.path();
|
||||
found = true;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1002,7 +1002,7 @@ VkTexture* CharacterRenderer::compositeTextures(const std::vector<std::string>&
|
|||
int dstX = 0, dstY = 0;
|
||||
int expectedW256 = 0, expectedH256 = 0; // Expected size at 256-base
|
||||
std::string pathLower = layerPaths[layer];
|
||||
for (auto& c : pathLower) c = std::tolower(c);
|
||||
for (auto& c : pathLower) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
|
||||
if (pathLower.find("faceupper") != std::string::npos) {
|
||||
dstX = faceUpperRegion256.x; dstY = faceUpperRegion256.y;
|
||||
|
|
@ -1220,7 +1220,7 @@ VkTexture* CharacterRenderer::compositeWithRegions(const std::string& basePath,
|
|||
// WoW 256-scale atlas coordinates (from CharComponentTextureSections)
|
||||
int dstX = 0, dstY = 0;
|
||||
std::string pathLower = ul;
|
||||
for (auto& c : pathLower) c = std::tolower(c);
|
||||
for (auto& c : pathLower) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
|
||||
// Scale factor from 256-base coordinates to actual canvas size
|
||||
int coordScale = width / 256;
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ std::shared_ptr<PendingTile> TerrainManager::prepareTile(int x, int y) {
|
|||
if (basePath.size() > 4) {
|
||||
extension = basePath.substr(basePath.size() - 4);
|
||||
std::string extLower = extension;
|
||||
for (char& c : extLower) c = std::tolower(c);
|
||||
for (char& c : extLower) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
if (extLower == ".wmo") {
|
||||
basePath = basePath.substr(0, basePath.size() - 4);
|
||||
}
|
||||
|
|
@ -612,7 +612,7 @@ std::shared_ptr<PendingTile> TerrainManager::prepareTile(int x, int y) {
|
|||
|
||||
if (m2Path.size() > 4) {
|
||||
std::string ext = m2Path.substr(m2Path.size() - 4);
|
||||
for (char& c : ext) c = std::tolower(c);
|
||||
for (char& c : ext) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
if (ext == ".mdx" || ext == ".mdl") {
|
||||
m2Path = m2Path.substr(0, m2Path.size() - 4) + ".m2";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -773,7 +773,7 @@ bool WMORenderer::loadModel(const pipeline::WMOModel& model, uint32_t id) {
|
|||
// Convert .mdx/.mdl to .m2
|
||||
if (m2Path.size() > 4) {
|
||||
std::string ext = m2Path.substr(m2Path.size() - 4);
|
||||
for (char& c : ext) c = std::tolower(c);
|
||||
for (char& c : ext) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
if (ext == ".mdx" || ext == ".mdl") {
|
||||
m2Path = m2Path.substr(0, m2Path.size() - 4) + ".m2";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -454,8 +454,9 @@ void AuthScreen::render(auth::AuthHandler& authHandler) {
|
|||
if (!usingStoredHash) {
|
||||
std::string upperUser = username;
|
||||
std::string upperPass = password;
|
||||
std::transform(upperUser.begin(), upperUser.end(), upperUser.begin(), ::toupper);
|
||||
std::transform(upperPass.begin(), upperPass.end(), upperPass.begin(), ::toupper);
|
||||
auto toUp = [](unsigned char c) { return static_cast<char>(std::toupper(c)); };
|
||||
std::transform(upperUser.begin(), upperUser.end(), upperUser.begin(), toUp);
|
||||
std::transform(upperPass.begin(), upperPass.end(), upperPass.begin(), toUp);
|
||||
std::string combined = upperUser + ":" + upperPass;
|
||||
auto hash = auth::Crypto::sha1(combined);
|
||||
savedPasswordHash = hexEncode(hash);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue