Enhance CMake configuration and improve string safety in source files

- Updated CMakeLists.txt to silence C++23 deprecation warnings and added definitions for intrinsic int128 support.
- Modified GitHub Actions workflow to handle missing asset directories gracefully and ensure correct versioning in Info.plist.
- Refactored string handling in multiple source files to use std::memcpy for safer string copying, preventing potential buffer overflows.
- Improved font loading logic and ensured consistent handling of theme properties in the editor.
This commit is contained in:
scawful
2025-09-27 22:03:03 -04:00
parent 332f050cf6
commit 660c3fd46f
8 changed files with 98 additions and 29 deletions

View File

@@ -1,5 +1,6 @@
#include "dungeon_object_selector.h"
#include <algorithm>
#include <iterator>
#include <cstring>
@@ -1046,8 +1047,10 @@ void DungeonObjectSelector::DrawCompactPropertiesEditor() {
static int music_id = 0;
// Copy current values
std::strncpy(room_name, properties.name.c_str(), sizeof(room_name) - 1);
room_name[sizeof(room_name) - 1] = '\0';
// Safe string copy with bounds checking
size_t name_len = std::min(properties.name.length(), sizeof(room_name) - 1);
std::memcpy(room_name, properties.name.c_str(), name_len);
room_name[name_len] = '\0';
dungeon_id = properties.dungeon_id;
floor_level = properties.floor_level;
is_boss_room = properties.is_boss_room;

View File

@@ -1,5 +1,6 @@
#include "editor_manager.h"
#include <algorithm>
#include <chrono>
#include <cstring>
@@ -2254,8 +2255,11 @@ void EditorManager::DrawSessionSwitcher() {
ImGui::SameLine();
if (ImGui::Button("Rename")) {
session_to_rename_ = i;
std::strncpy(session_rename_buffer_, session.GetDisplayName().c_str(), sizeof(session_rename_buffer_) - 1);
session_rename_buffer_[sizeof(session_rename_buffer_) - 1] = '\0';
// Safe string copy with bounds checking
const std::string& name = session.GetDisplayName();
size_t copy_len = std::min(name.length(), sizeof(session_rename_buffer_) - 1);
std::memcpy(session_rename_buffer_, name.c_str(), copy_len);
session_rename_buffer_[copy_len] = '\0';
show_session_rename_dialog_ = true;
}
@@ -2431,8 +2435,11 @@ void EditorManager::DrawSessionManager() {
ImGui::SameLine();
if (ImGui::Button("Rename")) {
session_to_rename_ = i;
std::strncpy(session_rename_buffer_, session.GetDisplayName().c_str(), sizeof(session_rename_buffer_) - 1);
session_rename_buffer_[sizeof(session_rename_buffer_) - 1] = '\0';
// Safe string copy with bounds checking
const std::string& name = session.GetDisplayName();
size_t copy_len = std::min(name.length(), sizeof(session_rename_buffer_) - 1);
std::memcpy(session_rename_buffer_, name.c_str(), copy_len);
session_rename_buffer_[copy_len] = '\0';
show_session_rename_dialog_ = true;
}