You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.6 KiB
74 lines
2.6 KiB
From db0282cbe00a64cc65ba445ea21928d72dc26d97 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
Date: Mon, 10 Jun 2019 08:50:59 -0700
|
|
Subject: [PATCH 03/11] CVE-2019-7574: Fix a buffer overread in
|
|
IMA_ADPCM_decode If data chunk was shorter than expected based on a WAV
|
|
format definition, IMA_ADPCM_decode() tried to read past the data chunk
|
|
buffer. This patch fixes it.
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
CVE-2019-7574
|
|
https://bugzilla.libsdl.org/show_bug.cgi?id=4496
|
|
|
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
|
--HG--
|
|
branch : SDL-1.2
|
|
---
|
|
src/audio/SDL_wave.c | 9 ++++++++-
|
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
|
|
index 21ee4dc3c..66f804421 100644
|
|
--- a/src/audio/SDL_wave.c
|
|
+++ b/src/audio/SDL_wave.c
|
|
@@ -331,7 +331,7 @@ static void Fill_IMA_ADPCM_block(Uint8 *decoded, Uint8 *encoded,
|
|
static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|
{
|
|
struct IMA_ADPCM_decodestate *state;
|
|
- Uint8 *freeable, *encoded, *decoded;
|
|
+ Uint8 *freeable, *encoded, *encoded_end, *decoded;
|
|
Sint32 encoded_len, samplesleft;
|
|
unsigned int c, channels;
|
|
|
|
@@ -347,6 +347,7 @@ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|
/* Allocate the proper sized output buffer */
|
|
encoded_len = *audio_len;
|
|
encoded = *audio_buf;
|
|
+ encoded_end = encoded + encoded_len;
|
|
freeable = *audio_buf;
|
|
*audio_len = (encoded_len/IMA_ADPCM_state.wavefmt.blockalign) *
|
|
IMA_ADPCM_state.wSamplesPerBlock*
|
|
@@ -362,6 +363,7 @@ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|
while ( encoded_len >= IMA_ADPCM_state.wavefmt.blockalign ) {
|
|
/* Grab the initial information for this block */
|
|
for ( c=0; c<channels; ++c ) {
|
|
+ if (encoded + 4 > encoded_end) goto invalid_size;
|
|
/* Fill the state information for this block */
|
|
state[c].sample = ((encoded[1]<<8)|encoded[0]);
|
|
encoded += 2;
|
|
@@ -384,6 +386,7 @@ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|
samplesleft = (IMA_ADPCM_state.wSamplesPerBlock-1)*channels;
|
|
while ( samplesleft > 0 ) {
|
|
for ( c=0; c<channels; ++c ) {
|
|
+ if (encoded + 4 > encoded_end) goto invalid_size;
|
|
Fill_IMA_ADPCM_block(decoded, encoded,
|
|
c, channels, &state[c]);
|
|
encoded += 4;
|
|
@@ -395,6 +398,10 @@ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|
}
|
|
SDL_free(freeable);
|
|
return(0);
|
|
+invalid_size:
|
|
+ SDL_SetError("Unexpected chunk length for an IMA ADPCM decoder");
|
|
+ SDL_free(freeable);
|
|
+ return(-1);
|
|
}
|
|
|
|
SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
|
|
--
|
|
2.21.0
|
|
|