]> git.sesse.net Git - vlc/commitdiff
* modules/codec/dts.c: fixes a buffer overflow with s/pdif.
authorGildas Bazin <gbazin@videolan.org>
Fri, 6 Feb 2004 18:15:44 +0000 (18:15 +0000)
committerGildas Bazin <gbazin@videolan.org>
Fri, 6 Feb 2004 18:15:44 +0000 (18:15 +0000)
* modules/access/cdda.c, modules/audio_output/file.c: endianness fixes for WAV header.

modules/access/cdda.c
modules/audio_output/file.c
modules/codec/dts.c

index a7c2d6307ca7fea9ad7827027e7d2ff79068ec94..2cc58522434574a4e5711012d9cc69c099759f50 100644 (file)
@@ -2,7 +2,7 @@
  * cdda.c : CD digital audio input module for vlc
  *****************************************************************************
  * Copyright (C) 2000, 2003 VideoLAN
- * $Id: cdda.c,v 1.13 2004/02/05 22:56:12 gbazin Exp $
+ * $Id: cdda.c,v 1.14 2004/02/06 18:15:44 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@netcourrier.com>
@@ -236,19 +236,19 @@ static int AccessOpen( vlc_object_t *p_this )
 
     /* Build a WAV header for the output data */
     memset( &p_sys->waveheader, 0, sizeof(WAVEHEADER) );
-    p_sys->waveheader.Format = 1 /*WAVE_FORMAT_PCM*/;
-    p_sys->waveheader.BitsPerSample = 16;
+    SetWLE( &p_sys->waveheader.Format, 1 ); /*WAVE_FORMAT_PCM*/
+    SetWLE( &p_sys->waveheader.BitsPerSample, 16);
     p_sys->waveheader.MainChunkID = VLC_FOURCC('R', 'I', 'F', 'F');
     p_sys->waveheader.Length = 0;                     /* we just don't know */
     p_sys->waveheader.ChunkTypeID = VLC_FOURCC('W', 'A', 'V', 'E');
     p_sys->waveheader.SubChunkID = VLC_FOURCC('f', 'm', 't', ' ');
-    p_sys->waveheader.SubChunkLength = 16;
-    p_sys->waveheader.Modus = 2;
-    p_sys->waveheader.SampleFreq = 44100;
-    p_sys->waveheader.BytesPerSample =
-        p_sys->waveheader.Modus * p_sys->waveheader.BitsPerSample / 8;
-    p_sys->waveheader.BytesPerSec =
-        p_sys->waveheader.BytesPerSample * p_sys->waveheader.SampleFreq;
+    SetDWLE( &p_sys->waveheader.SubChunkLength, 16);
+    SetWLE( &p_sys->waveheader.Modus, 2);
+    SetDWLE( &p_sys->waveheader.SampleFreq, 44100);
+    SetWLE( &p_sys->waveheader.BytesPerSample,
+            2 /*Modus*/ * 16 /*BitsPerSample*/ / 8 );
+    SetDWLE( &p_sys->waveheader.BytesPerSec,
+             16 /*BytesPerSample*/ * 44100 /*SampleFreq*/ );
     p_sys->waveheader.DataChunkID = VLC_FOURCC('d', 'a', 't', 'a');
     p_sys->waveheader.DataLength = 0;                 /* we just don't know */
     p_sys->i_header_pos = 0;
index 19a56e7f019c7a7d03d0f3f71522ba55c5f91402..cd67348620961ddfa9412b3f8397d7a07e5ae79a 100644 (file)
@@ -2,7 +2,7 @@
  * file.c : audio output which writes the samples to a file
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: file.c,v 1.28 2004/02/03 23:31:46 gbazin Exp $
+ * $Id: file.c,v 1.29 2004/02/06 18:15:44 gbazin Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Gildas Bazin <gbazin@netcourrier.com>
@@ -272,6 +272,15 @@ static int Open( vlc_object_t * p_this )
         wh->DataChunkID = VLC_FOURCC('d', 'a', 't', 'a');
         wh->DataLength = 0;                /* temp, to be filled in as we go */
 
+        /* Header -> little endian format */
+        SetWLE( &wh->Format, wh->Format );
+        SetWLE( &wh->BitsPerSample, wh->BitsPerSample );
+        SetDWLE( &wh->SubChunkLength, wh->SubChunkLength );
+        SetWLE( &wh->Modus, wh->Modus );
+        SetDWLE( &wh->SampleFreq, wh->SampleFreq );
+        SetWLE( &wh->BytesPerSample, wh->BytesPerSample );
+        SetDWLE( &wh->BytesPerSec, wh->BytesPerSec );
+
         if( fwrite( wh, sizeof(WAVEHEADER), 1,
                     p_aout->output.p_sys->p_file ) != 1 )
         {
@@ -302,6 +311,13 @@ static void Close( vlc_object_t * p_this )
         {
             msg_Err( p_aout, "seek error (%s)", strerror(errno) );
         }
+
+        /* Header -> little endian format */
+        SetDWLE( &p_aout->output.p_sys->waveh.Length,
+                 p_aout->output.p_sys->waveh.Length );
+        SetDWLE( &p_aout->output.p_sys->waveh.DataLength,
+                 p_aout->output.p_sys->waveh.DataLength );
+
         if( fwrite( &p_aout->output.p_sys->waveh, sizeof(WAVEHEADER), 1,
                     p_aout->output.p_sys->p_file ) != 1 )
         {
index fd44f79d4814a035810fb592192b2cc59975d303..ea0fce4165b1fb43ec14652b89ce27511ea087c7 100644 (file)
@@ -2,7 +2,7 @@
  * dts.c: parse DTS audio sync info and packetize the stream
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: dts.c,v 1.15 2004/02/04 23:55:03 gbazin Exp $
+ * $Id: dts.c,v 1.16 2004/02/06 18:15:44 gbazin Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Gildas Bazin <gbazin@netcourrier.com>
@@ -367,8 +367,9 @@ static aout_buffer_t *GetAoutBuffer( decoder_t *p_dec )
     decoder_sys_t *p_sys = p_dec->p_sys;
     aout_buffer_t *p_buf;
 
-    /* Hack for DTS S/PDIF filter which needs to send 3 frames at a time */
-    p_buf = p_dec->pf_aout_buffer_new( p_dec, p_sys->i_frame_length * 3 );
+    /* Hack for DTS S/PDIF filter which needs to send 3 frames at a time
+     * (plus a few header bytes) */
+    p_buf = p_dec->pf_aout_buffer_new( p_dec, p_sys->i_frame_length * 4 );
     if( p_buf == NULL ) return NULL;
     p_buf->i_nb_samples = p_sys->i_frame_length;
     p_buf->i_nb_bytes = p_sys->i_frame_size;