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.
This commit is contained in:
Norihiro Kamae
2022-08-03 04:17:19 +09:00
committed by Ryan Foster
parent ffcc3acd9d
commit 505b76e8a7

View File

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