]> git.sesse.net Git - vlc/commitdiff
flac: fix decoding samples with too large extradata
authorRafaël Carré <funman@videolan.org>
Tue, 2 Jul 2013 09:39:42 +0000 (11:39 +0200)
committerRafaël Carré <funman@videolan.org>
Tue, 2 Jul 2013 09:39:42 +0000 (11:39 +0200)
Only use the first 34 or 42 bytes (streaminfo block)

Sample:
0109c7dd02be4e673824fe156bc4cb66  [UTW-THORA] Evangelion 3.33 You Can (Not) Redo [BD][1080p,x264,flac][F2060CF5] sample.mka

modules/codec/flac.c

index 1002ffd681b36c2043e6d3287e81bea08aaaad5e..6dac9cc7fcf51e194f31f152d1513ff66ec31f4a 100644 (file)
@@ -381,11 +381,18 @@ static void ProcessHeader( decoder_t *p_dec )
     /* Decode STREAMINFO */
     msg_Dbg( p_dec, "decode STREAMINFO" );
     size_t i_extra = p_dec->fmt_in.i_extra;
+    static const char header[4] = { 'f', 'L', 'a', 'C' };
+
+    if (i_extra > 42 && !memcmp(p_dec->fmt_in.p_extra, header, 4))
+        i_extra = 42;
+    else if (i_extra > 34 && memcmp(p_dec->fmt_in.p_extra, header, 4))
+        i_extra = 34;
+
     switch (i_extra) {
     case 34:
         p_sys->p_block = block_Alloc( 8 + i_extra );
         memcpy( p_sys->p_block->p_buffer + 8, p_dec->fmt_in.p_extra, i_extra );
-        memcpy( p_sys->p_block->p_buffer, "fLaC", 4);
+        memcpy( p_sys->p_block->p_buffer, header, 4);
         uint8_t *p = p_sys->p_block->p_buffer;
         p[4] = 0x80 | 0; /* STREAMINFO faked as last block */
         p[5] = 0;