Browse Source

win-capture: Replace invocations of sprintf with snprintf

Fixes deprecation warnings in Xcode 14/clang on macOS and reduces
chance of buffer overflows.
PatTheMav 3 years ago
parent
commit
b417df7d95

+ 1 - 1
plugins/win-capture/game-capture.c

@@ -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");

+ 2 - 1
plugins/win-capture/graphics-hook/graphics-hook.c

@@ -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) {