From b87960ae5d7ae1e45aed3712c0f507a4d7af73fd Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Fri, 6 Feb 2009 10:51:28 +0200 Subject: [PATCH] binary registry: Rewrite sanity check to actualy catch something. The previous commit was bogus, as was the check before. We just point m to the file data, so neither it nor its members will be NULL. Better check if we have enough data. --- gst/gstregistrybinary.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c index 54a27d45b6..cd373e9ab9 100644 --- a/gst/gstregistrybinary.c +++ b/gst/gstregistrybinary.c @@ -786,12 +786,13 @@ gst_registry_binary_check_magic (gchar ** in, gsize size) align (*in); GST_DEBUG ("Reading/casting for GstBinaryRegistryMagic at address %p", *in); - unpack_element (*in, m, GstBinaryRegistryMagic); - if (m == NULL || &m->magic == NULL || &m->version == NULL) { - GST_WARNING ("Binary registry magic structure is broken"); + if (size < sizeof (GstBinaryRegistryMagic)) { + GST_WARNING ("Not enough data for binary registry magic structure"); return -1; } + unpack_element (*in, m, GstBinaryRegistryMagic); + if (strncmp (m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) != 0) { GST_WARNING