--- modules/access/mms/mmsh.c.orig	2005-12-11 16:36:23.000000000 -0500
+++ modules/access/mms/mmsh.c	2005-12-15 09:00:19.836689810 -0500
@@ -712,17 +712,37 @@
     memset( p_ck, 0, sizeof( chunk_t ) );
 
     /* Read the chunk header */
-    if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer, 12, VLC_TRUE ) < 12 )
-    {
-        /* msg_Err( p_access, "cannot read data" ); */
-        return VLC_EGENERIC;
-    }
-
+    /* Some headers are short, like 0x4324. Reading 12 bytes will cause us
+     * to lose synchronization with the stream. Just read to the length
+     * (4 bytes), decode and then read up to 8 additional bytes to get the
+     * entire header.
+     */
+    if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer, 4, VLC_TRUE ) < 4 )
+      {
+	/* msg_Err( p_access, "cannot read data" ); */
+	return VLC_EGENERIC;
+      }
     p_ck->i_type      = GetWLE( p_sys->buffer);
     p_ck->i_size      = GetWLE( p_sys->buffer + 2);
+    int restsize = p_ck->i_size;
+    if (restsize > 8)
+      restsize = 8;
+    if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer + 4, restsize, VLC_TRUE ) < restsize )
+      {
+        /* msg_Err( p_access, "cannot read data" ); */
+        return VLC_EGENERIC;
+      }
     p_ck->i_sequence  = GetDWLE( p_sys->buffer + 4);
     p_ck->i_unknown   = GetWLE( p_sys->buffer + 8);
-    p_ck->i_size2     = GetWLE( p_sys->buffer + 10);
+    /* Set i_size2 to 8 if this header was short, since a real value won't be
+     * present in the buffer. Using 8 avoid reading additional data for the
+     * packet.
+     */
+    if (restsize < 8) {
+      p_ck->i_size2 = 8;
+    } else {
+      p_ck->i_size2     = GetWLE( p_sys->buffer + 10);
+    }
     p_ck->p_data      = p_sys->buffer + 12;
     p_ck->i_data      = p_ck->i_size2 - 8;
 
@@ -739,7 +759,9 @@
             return VLC_EGENERIC;
         }
     }
-    else if( p_ck->i_type != 0x4824 && p_ck->i_type != 0x4424 )
+    /* 0x4324 is CHUNK_TYPE_RESET. We can safely ignore it: a new stream will
+     * follow with a sequence of 0 */
+    else if( p_ck->i_type != 0x4824 && p_ck->i_type != 0x4424 && p_ck->i_type != 0x4324)
     {
         msg_Err( p_access, "invalid chunk FATAL (0x%x)", p_ck->i_type );
         return VLC_EGENERIC;
