From ab728fe92f36806271ea058ad900a6b97bd3d3ff Mon Sep 17 00:00:00 2001 From: Gildas Bazin Date: Fri, 6 Feb 2004 18:15:44 +0000 Subject: [PATCH] * modules/codec/dts.c: fixes a buffer overflow with s/pdif. * modules/access/cdda.c, modules/audio_output/file.c: endianness fixes for WAV header. --- modules/access/cdda.c | 20 ++++++++++---------- modules/audio_output/file.c | 18 +++++++++++++++++- modules/codec/dts.c | 7 ++++--- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/modules/access/cdda.c b/modules/access/cdda.c index a7c2d6307c..2cc5852243 100644 --- a/modules/access/cdda.c +++ b/modules/access/cdda.c @@ -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 * Gildas Bazin @@ -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; diff --git a/modules/audio_output/file.c b/modules/audio_output/file.c index 19a56e7f01..cd67348620 100644 --- a/modules/audio_output/file.c +++ b/modules/audio_output/file.c @@ -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 * Gildas Bazin @@ -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 ) { diff --git a/modules/codec/dts.c b/modules/codec/dts.c index fd44f79d48..ea0fce4165 100644 --- a/modules/codec/dts.c +++ b/modules/codec/dts.c @@ -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 * Gildas Bazin @@ -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; -- 2.39.5