Index: gst/multipart/multipartdemux.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-good/gst/multipart/multipartdemux.c,v
retrieving revision 1.16
diff -u -u -r1.16 multipartdemux.c
--- gst/multipart/multipartdemux.c	28 Jul 2006 16:17:17 -0000	1.16
+++ gst/multipart/multipartdemux.c	8 Aug 2006 08:05:32 -0000
@@ -334,13 +334,27 @@
   data = gst_adapter_peek (multipart->adapter, datalen);
   dataend = data + datalen;
 
+  /* Skip leading whitespace, pos endposition should at least leave space for
+   * the boundary and a \n */
+  for (pos = (guint8 *)data; pos < dataend - 4 && g_ascii_isspace(*pos) ; pos++)
+    ;
+
+  if (pos >= dataend - 4) {
+    return MULTIPART_NEED_MORE_DATA;
+  }
+
+  if (G_UNLIKELY(pos[0] != '-' || pos[1] != '-')) {
+    GST_DEBUG_OBJECT (multipart, "No boundary available");
+    goto wrong_header;
+  }
+
   /* First the boundary */
-  if (!get_line_end (data, dataend, &end, &next))
+  if (!get_line_end (pos, dataend, &end, &next))
     return MULTIPART_NEED_MORE_DATA;
 
   /* Ignore the leading -- */
-  boundary_len = end - data - 2;
-  boundary = (gchar *) data + 2;
+  boundary_len = end - pos - 2;
+  boundary = (gchar *) pos + 2;
   if (boundary_len < 1) {
     GST_DEBUG_OBJECT (multipart, "No boundary available");
     goto wrong_header;
