Silence the last two C4996 warnings in our code
hook_registry.cpp still used strncpy for the hook-name copy (the same class the log-ring fix addressed) -- replace with a bounded memcpy. coop_vk_layer.cpp's debug logger used _wfopen -- switch to _wfopen_s. Both were the only remaining C4996s in our own code.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "hook_registry.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
@@ -35,8 +36,9 @@ int hook_register(const char* name, std::uint32_t subsystem)
|
||||
return -1; // table full
|
||||
}
|
||||
Slot& s = g_slots[count];
|
||||
std::strncpy(s.name, name, sizeof(s.name) - 1);
|
||||
s.name[sizeof(s.name) - 1] = '\0';
|
||||
const std::size_t len = std::min(std::strlen(name), sizeof(s.name) - 1);
|
||||
std::memcpy(s.name, name, len);
|
||||
s.name[len] = '\0';
|
||||
s.subsystem.store(subsystem, std::memory_order_relaxed);
|
||||
s.installed.store(0, std::memory_order_relaxed);
|
||||
s.calls.store(0, std::memory_order_relaxed);
|
||||
|
||||
Reference in New Issue
Block a user