From 505b76e8a723ae5b671bb8ae776d3e08b969f227 Mon Sep 17 00:00:00 2001 From: Norihiro Kamae Date: Wed, 3 Aug 2022 04:17:19 +0900 Subject: [PATCH] libobs: Reject plugins compiled with newer libobs Check obs_module_ver and reject if the plugin is built with a newer libobs major/minor version. --- libobs/obs-module.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libobs/obs-module.c b/libobs/obs-module.c index 5fe3b8a8f..cc913c4f1 100644 --- a/libobs/obs-module.c +++ b/libobs/obs-module.c @@ -124,6 +124,14 @@ int obs_open_module(obs_module_t **module, const char *path, const char *data_pa if (errorcode != MODULE_SUCCESS) return errorcode; + /* Reject plugins compiled with a newer libobs. Patch version (lower 16-bit) is ignored. */ + uint32_t ver = mod.ver ? mod.ver() & 0xFFFF0000 : 0; + if (ver > LIBOBS_API_VER) { + blog(LOG_WARNING, "Module '%s' compiled with newer libobs %d.%d", path, (ver >> 24) & 0xFF, + (ver >> 16) & 0xFF); + return MODULE_INCOMPATIBLE_VER; + } + mod.bin_path = bstrdup(path); mod.file = strrchr(mod.bin_path, '/'); mod.file = (!mod.file) ? mod.bin_path : (mod.file + 1);