mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-24 02:34:23 -05:00
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.
This commit is contained in:
@@ -257,7 +257,10 @@ static bool av1_supported(void)
|
||||
bool av1_supported = false;
|
||||
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);
|
||||
|
||||
os_process_pipe_t *pp = os_process_pipe_create(cmd.array, "r");
|
||||
@@ -310,8 +313,6 @@ fail:
|
||||
config_close(config);
|
||||
dstr_free(&caps_str);
|
||||
dstr_free(&cmd);
|
||||
if (test_exe)
|
||||
bfree(test_exe);
|
||||
|
||||
return av1_supported;
|
||||
}
|
||||
|
||||
@@ -2230,7 +2230,9 @@ try {
|
||||
std::stringstream cmd;
|
||||
std::string caps_str;
|
||||
|
||||
cmd << '"';
|
||||
cmd << test_exe;
|
||||
cmd << '"';
|
||||
enum_graphics_device_luids(enum_luids, &cmd);
|
||||
|
||||
os_process_pipe_t *pp = os_process_pipe_create(cmd.str().c_str(), "r");
|
||||
|
||||
@@ -215,7 +215,10 @@ void check_adapters(struct adapter_info *adapters, size_t *adapter_count)
|
||||
const char *error = nullptr;
|
||||
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);
|
||||
|
||||
pp = os_process_pipe_create(cmd.array, "r");
|
||||
@@ -276,7 +279,6 @@ fail:
|
||||
dstr_free(&caps_str);
|
||||
dstr_free(&cmd);
|
||||
os_process_pipe_destroy(pp);
|
||||
bfree(test_exe);
|
||||
}
|
||||
|
||||
/* (Lain) Functions currently unused */
|
||||
|
||||
@@ -163,6 +163,7 @@ bool load_graphics_offsets(bool is32bit, bool use_hook_address_cache,
|
||||
struct dstr config_ini = {0};
|
||||
struct dstr offset_exe = {0};
|
||||
struct dstr str = {0};
|
||||
struct dstr cmd = {0};
|
||||
os_process_pipe_t *pp;
|
||||
bool success = false;
|
||||
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");
|
||||
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) {
|
||||
blog(LOG_INFO, "load_graphics_offsets: Failed to start '%s'",
|
||||
offset_exe.array);
|
||||
@@ -219,9 +224,9 @@ bool load_graphics_offsets(bool is32bit, bool use_hook_address_cache,
|
||||
os_process_pipe_destroy(pp);
|
||||
|
||||
error:
|
||||
bfree(offset_exe_path);
|
||||
dstr_free(&offset_exe);
|
||||
dstr_free(&str);
|
||||
dstr_free(&cmd);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user