From e2aa76db79328b7f61536dd19d0373cf920395ad Mon Sep 17 00:00:00 2001 From: Seppo Yli-Olli Date: Tue, 21 Apr 2020 13:33:54 +0300 Subject: [PATCH] Have strict version check for OpenH264 to avoid ABI issues This fixes #1274 and no longer trusts soname alone Part-of: --- ext/openh264/gstopenh264plugin.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ext/openh264/gstopenh264plugin.c b/ext/openh264/gstopenh264plugin.c index 99c428ab7d..10b0d4f071 100644 --- a/ext/openh264/gstopenh264plugin.c +++ b/ext/openh264/gstopenh264plugin.c @@ -32,17 +32,29 @@ #endif #include +#include +#include +#include #include "gstopenh264dec.h" #include "gstopenh264enc.h" static gboolean plugin_init (GstPlugin * plugin) { - gst_element_register (plugin, "openh264dec", GST_RANK_MARGINAL, - GST_TYPE_OPENH264DEC); - gst_element_register (plugin, "openh264enc", GST_RANK_MARGINAL, - GST_TYPE_OPENH264ENC); - + /* g_stCodecVersion is the version detected at build time as defined in the + * headers and WelsGetCodecVersion() is the version detected at runtime. + * This is a safeguard to avoid crashes since OpenH264 has been changing + * ABI without changing the SONAME. + */ + OpenH264Version libver = WelsGetCodecVersion (); + if (memcmp (&libver, &g_stCodecVersion, sizeof (libver))) { + gst_element_register (plugin, "openh264dec", GST_RANK_MARGINAL, + GST_TYPE_OPENH264DEC); + gst_element_register (plugin, "openh264enc", GST_RANK_MARGINAL, + GST_TYPE_OPENH264ENC); + } else { + GST_ERROR ("Incorrect library version loaded, expecting %s", g_strCodecVer); + } return TRUE; }