win-capture: Replace invocations of sprintf with snprintf

Fixes deprecation warnings in Xcode 14/clang on macOS and reduces
chance of buffer overflows.
This commit is contained in:
PatTheMav
2022-07-28 20:07:51 +02:00
parent d87467666b
commit b417df7d95
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -823,7 +823,7 @@ static void pipe_log(void *param, uint8_t *data, size_t size)
static inline bool init_pipe(struct game_capture *gc)
{
char name[64];
sprintf(name, "%s%lu", PIPE_NAME, gc->process_id);
snprintf(name, sizeof(name), "%s%lu", PIPE_NAME, gc->process_id);
if (!ipc_pipe_server_start(&gc->pipe, name, pipe_log, gc)) {
warn("init_pipe: failed to start pipe");
@@ -65,7 +65,8 @@ static inline void wait_for_dll_main_finish(HANDLE thread_handle)
bool init_pipe(void)
{
char new_name[64];
sprintf(new_name, "%s%lu", PIPE_NAME, GetCurrentProcessId());
snprintf(new_name, sizeof(new_name), "%s%lu", PIPE_NAME,
GetCurrentProcessId());
const bool success = ipc_pipe_client_open(&pipe, new_name);
if (!success) {