浏览代码

plugins: Quote program paths used in os_process_pipe_create

These end up being passed to CreateProcessW, so paths with spaces in the
name may be open to misinterpretation by the OS.
Richard Stanway 2 年之前
父节点
当前提交
d3ab68c5ca

+ 4 - 3
plugins/obs-ffmpeg/obs-nvenc-helpers.c

@@ -257,7 +257,10 @@ static bool av1_supported(void)
 	bool av1_supported = false;
 	bool av1_supported = false;
 	config_t *config = NULL;
 	config_t *config = NULL;
 
 
-	dstr_copy(&cmd, test_exe);
+	dstr_init_move_array(&cmd, test_exe);
+	dstr_insert_ch(&cmd, 0, '\"');
+	dstr_cat(&cmd, "\"");
+
 	enum_graphics_device_luids(enum_luids, &cmd);
 	enum_graphics_device_luids(enum_luids, &cmd);
 
 
 	os_process_pipe_t *pp = os_process_pipe_create(cmd.array, "r");
 	os_process_pipe_t *pp = os_process_pipe_create(cmd.array, "r");
@@ -310,8 +313,6 @@ fail:
 		config_close(config);
 		config_close(config);
 	dstr_free(&caps_str);
 	dstr_free(&caps_str);
 	dstr_free(&cmd);
 	dstr_free(&cmd);
-	if (test_exe)
-		bfree(test_exe);
 
 
 	return av1_supported;
 	return av1_supported;
 }
 }

+ 2 - 0
plugins/obs-ffmpeg/texture-amf.cpp

@@ -2230,7 +2230,9 @@ try {
 	std::stringstream cmd;
 	std::stringstream cmd;
 	std::string caps_str;
 	std::string caps_str;
 
 
+	cmd << '"';
 	cmd << test_exe;
 	cmd << test_exe;
+	cmd << '"';
 	enum_graphics_device_luids(enum_luids, &cmd);
 	enum_graphics_device_luids(enum_luids, &cmd);
 
 
 	os_process_pipe_t *pp = os_process_pipe_create(cmd.str().c_str(), "r");
 	os_process_pipe_t *pp = os_process_pipe_create(cmd.str().c_str(), "r");

+ 4 - 2
plugins/obs-qsv11/common_utils_windows.cpp

@@ -215,7 +215,10 @@ void check_adapters(struct adapter_info *adapters, size_t *adapter_count)
 	const char *error = nullptr;
 	const char *error = nullptr;
 	size_t config_adapter_count;
 	size_t config_adapter_count;
 
 
-	dstr_copy(&cmd, test_exe);
+	dstr_init_move_array(&cmd, test_exe);
+	dstr_insert_ch(&cmd, 0, '\"');
+	dstr_cat(&cmd, "\"");
+
 	enum_graphics_device_luids(enum_luids, &cmd);
 	enum_graphics_device_luids(enum_luids, &cmd);
 
 
 	pp = os_process_pipe_create(cmd.array, "r");
 	pp = os_process_pipe_create(cmd.array, "r");
@@ -276,7 +279,6 @@ fail:
 	dstr_free(&caps_str);
 	dstr_free(&caps_str);
 	dstr_free(&cmd);
 	dstr_free(&cmd);
 	os_process_pipe_destroy(pp);
 	os_process_pipe_destroy(pp);
-	bfree(test_exe);
 }
 }
 
 
 /* (Lain) Functions currently unused */
 /* (Lain) Functions currently unused */

+ 7 - 2
plugins/win-capture/load-graphics-offsets.c

@@ -163,6 +163,7 @@ bool load_graphics_offsets(bool is32bit, bool use_hook_address_cache,
 	struct dstr config_ini = {0};
 	struct dstr config_ini = {0};
 	struct dstr offset_exe = {0};
 	struct dstr offset_exe = {0};
 	struct dstr str = {0};
 	struct dstr str = {0};
+	struct dstr cmd = {0};
 	os_process_pipe_t *pp;
 	os_process_pipe_t *pp;
 	bool success = false;
 	bool success = false;
 	char data[2048];
 	char data[2048];
@@ -177,7 +178,11 @@ bool load_graphics_offsets(bool is32bit, bool use_hook_address_cache,
 	dstr_cat(&offset_exe, is32bit ? "32.exe" : "64.exe");
 	dstr_cat(&offset_exe, is32bit ? "32.exe" : "64.exe");
 	offset_exe_path = obs_module_file(offset_exe.array);
 	offset_exe_path = obs_module_file(offset_exe.array);
 
 
-	pp = os_process_pipe_create(offset_exe_path, "r");
+	dstr_init_move_array(&cmd, offset_exe_path);
+	dstr_insert_ch(&cmd, 0, '\"');
+	dstr_cat(&cmd, "\"");
+
+	pp = os_process_pipe_create(cmd.array, "r");
 	if (!pp) {
 	if (!pp) {
 		blog(LOG_INFO, "load_graphics_offsets: Failed to start '%s'",
 		blog(LOG_INFO, "load_graphics_offsets: Failed to start '%s'",
 		     offset_exe.array);
 		     offset_exe.array);
@@ -219,9 +224,9 @@ bool load_graphics_offsets(bool is32bit, bool use_hook_address_cache,
 	os_process_pipe_destroy(pp);
 	os_process_pipe_destroy(pp);
 
 
 error:
 error:
-	bfree(offset_exe_path);
 	dstr_free(&offset_exe);
 	dstr_free(&offset_exe);
 	dstr_free(&str);
 	dstr_free(&str);
+	dstr_free(&cmd);
 	return success;
 	return success;
 }
 }