From f48b210d6124c49b30effaef87acc0fad4cc9a3a Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Fri, 7 Dec 2018 22:58:12 +0100 Subject: [PATCH] win-capture: Improve reading from get-graphics-offsets Increase the buffer size to read the response in one call if possible, and cause an error condition with log message if the offsets string is empty. --- plugins/win-capture/load-graphics-offsets.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/win-capture/load-graphics-offsets.c b/plugins/win-capture/load-graphics-offsets.c index 5a3167f4b..66a0aafcf 100644 --- a/plugins/win-capture/load-graphics-offsets.c +++ b/plugins/win-capture/load-graphics-offsets.c @@ -161,7 +161,7 @@ bool load_graphics_offsets(bool is32bit, const char *config_path) struct dstr str = {0}; os_process_pipe_t *pp; bool success = false; - char data[128]; + char data[2048]; #ifndef _WIN64 if (!is32bit && !is_64_bit_windows()) { @@ -181,13 +181,19 @@ bool load_graphics_offsets(bool is32bit, const char *config_path) } for (;;) { - size_t len = os_process_pipe_read(pp, (uint8_t*)data, 128); + size_t len = os_process_pipe_read(pp, (uint8_t*)data, sizeof(data)); if (!len) break; dstr_ncat(&str, data, len); } + if (dstr_is_empty(&str)) { + blog(LOG_INFO, "load_graphics_offsets: Failed to read " + "from '%s'", offset_exe.array); + goto error; + } + dstr_copy(&config_ini, config_path); dstr_cat(&config_ini, is32bit ? "32.ini" : "64.ini");