fuzzing: Compilation fixes

This commit is contained in:
Edward Hervey 2017-10-31 08:03:48 +01:00 committed by Edward Hervey
parent 87e1f69b19
commit 80d8fcec0c

View file

@ -26,9 +26,9 @@
#include <glib.h> #include <glib.h>
#include <gst/gst.h> #include <gst/gst.h>
GST_PLUGIN_STATIC_DECLARE(coreelements); GST_PLUGIN_STATIC_DECLARE (coreelements);
GST_PLUGIN_STATIC_DECLARE(typefindfunctions); GST_PLUGIN_STATIC_DECLARE (typefindfunctions);
GST_PLUGIN_STATIC_DECLARE(app); GST_PLUGIN_STATIC_DECLARE (app);
/* push-based typefind fuzzing target /* push-based typefind fuzzing target
* *
@ -42,22 +42,15 @@ GST_PLUGIN_STATIC_DECLARE(app);
* *
**/ **/
static void int
appsrc_configuration (GstDiscoverer *dc, GstElement *source, gpointer data) LLVMFuzzerTestOneInput (const guint8 * data, size_t size)
{
GstBuffer *buf;
GstFlowReturn ret;
/* Create buffer from fuzztesting_data which shouldn't be freed */
}
int LLVMFuzzerTestOneInput(const guint8 *data, size_t size)
{ {
GError *err = NULL; GError *err = NULL;
static gboolean initialized = 0; static gboolean initialized = 0;
GstElement *pipeline, *source, *typefind, *fakesink; GstElement *pipeline, *source, *typefind, *fakesink;
GstBuffer *buf; GstBuffer *buf;
GstFlowReturn flowret; GstFlowReturn flowret;
GstState state;
if (!initialized) { if (!initialized) {
/* We want critical warnings to assert so we can fix them /* We want critical warnings to assert so we can fix them
@ -67,9 +60,9 @@ int LLVMFuzzerTestOneInput(const guint8 *data, size_t size)
/* Only initialize and register plugins once */ /* Only initialize and register plugins once */
gst_init (NULL, NULL); gst_init (NULL, NULL);
GST_PLUGIN_STATIC_REGISTER(coreelements); GST_PLUGIN_STATIC_REGISTER (coreelements);
GST_PLUGIN_STATIC_REGISTER(typefindfunctions); GST_PLUGIN_STATIC_REGISTER (typefindfunctions);
GST_PLUGIN_STATIC_REGISTER(app); GST_PLUGIN_STATIC_REGISTER (app);
} }
/* Create the pipeline */ /* Create the pipeline */
@ -83,16 +76,16 @@ int LLVMFuzzerTestOneInput(const guint8 *data, size_t size)
/* Set pipeline to READY so we can provide data to appsrc */ /* Set pipeline to READY so we can provide data to appsrc */
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
buf = gst_buffer_new_wrapped_full (0, (gpointer) data, size, buf = gst_buffer_new_wrapped_full (0, (gpointer) data, size,
0, size, NULL, NULL); 0, size, NULL, NULL);
g_object_set (G_OBJECT (source), "size", size, NULL); g_object_set (G_OBJECT (source), "size", size, NULL);
g_signal_emit_by_name (G_OBJECT(source), "push-buffer", buf, &ret); g_signal_emit_by_name (G_OBJECT (source), "push-buffer", buf, &flowret);
gst_buffer_unref (buf); gst_buffer_unref (buf);
/* Set pipeline to PAUSED and wait (typefind will either fail or succeed) */ /* Set pipeline to PAUSED and wait (typefind will either fail or succeed) */
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
/* wait until state change either completes or fails */ /* wait until state change either completes or fails */
sret = gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, -1); gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL, -1);
/* Go back to NULL */ /* Go back to NULL */
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
@ -101,5 +94,4 @@ int LLVMFuzzerTestOneInput(const guint8 *data, size_t size)
gst_object_unref (pipeline); gst_object_unref (pipeline);
return 0; return 0;
} }