mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-03 04:52:28 +00:00
registry: Also check the binary registry chunk version of the child.
When trying to find a function plugin-scanner, include a check on the version of the binary registry chunks it sends, to make sure it's what we understand.
This commit is contained in:
parent
8bf3d8cec2
commit
97d6c854ae
1 changed files with 40 additions and 18 deletions
|
@ -39,9 +39,12 @@
|
||||||
|
|
||||||
#include <gst/gstpluginloader.h>
|
#include <gst/gstpluginloader.h>
|
||||||
#include <gst/gstregistrychunks.h>
|
#include <gst/gstregistrychunks.h>
|
||||||
|
#include <gst/gstregistrybinary.h>
|
||||||
|
|
||||||
/* IMPORTANT: Bump the version number if the plugin loader protocol changes */
|
/* IMPORTANT: Bump the version number if the plugin loader packet protocol
|
||||||
static const guint32 loader_protocol_version = 1;
|
* changes. Changes in the binary registry format are handled by bumps
|
||||||
|
* in the GST_MAGIC_BINARY_VERSION_STR as before */
|
||||||
|
static const guint32 loader_protocol_version = 2;
|
||||||
|
|
||||||
#define GST_CAT_DEFAULT GST_CAT_PLUGIN_LOADING
|
#define GST_CAT_DEFAULT GST_CAT_PLUGIN_LOADING
|
||||||
|
|
||||||
|
@ -88,8 +91,6 @@ struct _GstPluginLoader
|
||||||
gboolean rx_done;
|
gboolean rx_done;
|
||||||
gboolean rx_got_sync;
|
gboolean rx_got_sync;
|
||||||
|
|
||||||
guint32 got_version;
|
|
||||||
|
|
||||||
/* Head and tail of the pending plugins list. List of
|
/* Head and tail of the pending plugins list. List of
|
||||||
PendingPluginEntry structs */
|
PendingPluginEntry structs */
|
||||||
GList *pending_plugins;
|
GList *pending_plugins;
|
||||||
|
@ -350,16 +351,10 @@ gst_plugin_loader_try_helper (GstPluginLoader * loader, gchar * location)
|
||||||
|
|
||||||
loader->tx_buf_write = loader->tx_buf_read = 0;
|
loader->tx_buf_write = loader->tx_buf_read = 0;
|
||||||
|
|
||||||
loader->got_version = (guint32) (-1);
|
|
||||||
put_packet (loader, PACKET_VERSION, 0, NULL, 0);
|
put_packet (loader, PACKET_VERSION, 0, NULL, 0);
|
||||||
if (!plugin_loader_sync_with_child (loader))
|
if (!plugin_loader_sync_with_child (loader))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
GST_LOG ("Got VERSION %u from child. Ours is %u", loader->got_version,
|
|
||||||
loader_protocol_version);
|
|
||||||
if (loader->got_version != loader_protocol_version)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
loader->child_running = TRUE;
|
loader->child_running = TRUE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -607,6 +602,32 @@ fail:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
check_protocol_version (GstPluginLoader * l, guint8 * payload,
|
||||||
|
guint payload_len)
|
||||||
|
{
|
||||||
|
guint32 got_version;
|
||||||
|
guint8 *binary_reg_ver;
|
||||||
|
|
||||||
|
if (payload_len < sizeof (guint32) + GST_MAGIC_BINARY_VERSION_LEN)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
got_version = GST_READ_UINT32_BE (payload);
|
||||||
|
GST_LOG ("Got VERSION %u from child. Ours is %u", got_version,
|
||||||
|
loader_protocol_version);
|
||||||
|
if (got_version != loader_protocol_version)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
binary_reg_ver = payload + sizeof (guint32);
|
||||||
|
if (strcmp ((gchar *) binary_reg_ver, GST_MAGIC_BINARY_VERSION_STR)) {
|
||||||
|
GST_LOG ("Binary chunk format of child is different. Ours: %s, child %s\n",
|
||||||
|
GST_MAGIC_BINARY_VERSION_STR, binary_reg_ver);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
};
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_rx_packet (GstPluginLoader * l,
|
handle_rx_packet (GstPluginLoader * l,
|
||||||
guint pack_type, guint32 tag, guint8 * payload, guint payload_len)
|
guint pack_type, guint32 tag, guint8 * payload, guint payload_len)
|
||||||
|
@ -700,16 +721,17 @@ handle_rx_packet (GstPluginLoader * l,
|
||||||
case PACKET_VERSION:
|
case PACKET_VERSION:
|
||||||
if (l->is_child) {
|
if (l->is_child) {
|
||||||
/* Respond with our reply - a version packet, with the version */
|
/* Respond with our reply - a version packet, with the version */
|
||||||
guint32 val;
|
const gint version_len =
|
||||||
GST_WRITE_UINT32_BE (&val, loader_protocol_version);
|
sizeof (guint32) + GST_MAGIC_BINARY_VERSION_LEN;
|
||||||
put_packet (l, PACKET_VERSION, tag, (guint8 *) & val, sizeof (guint32));
|
guint8 version_info[sizeof (guint32) + GST_MAGIC_BINARY_VERSION_LEN];
|
||||||
|
memset (version_info, 0, version_len);
|
||||||
|
GST_WRITE_UINT32_BE (version_info, loader_protocol_version);
|
||||||
|
memcpy (version_info + sizeof (guint32), GST_MAGIC_BINARY_VERSION_STR,
|
||||||
|
strlen (GST_MAGIC_BINARY_VERSION_STR));
|
||||||
|
put_packet (l, PACKET_VERSION, tag, version_info, version_len);
|
||||||
GST_LOG ("Got VERSION in child - replying %u", loader_protocol_version);
|
GST_LOG ("Got VERSION in child - replying %u", loader_protocol_version);
|
||||||
} else {
|
} else {
|
||||||
if (payload_len == sizeof (loader_protocol_version)) {
|
res = check_protocol_version (l, payload, payload_len);
|
||||||
l->got_version = GST_READ_UINT32_BE (payload);
|
|
||||||
} else {
|
|
||||||
res = FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue