[vlc-commits] flac: fix decoding samples with too large extradata

Rafaël Carré git at videolan.org
Tue Jul 2 11:40:54 CEST 2013


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Tue Jul  2 11:39:42 2013 +0200| [ac636adefd0543904475e68d619e127950be990d] | committer: Rafaël Carré

flac: fix decoding samples with too large extradata

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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ac636adefd0543904475e68d619e127950be990d
---

 modules/codec/flac.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/modules/codec/flac.c b/modules/codec/flac.c
index 1002ffd..6dac9cc 100644
--- a/modules/codec/flac.c
+++ b/modules/codec/flac.c
@@ -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;



More information about the vlc-commits mailing list