|
|
6ed69d |
From 730c8b917e7deecc3cdf9ac9eb20e2b7e6450356 Mon Sep 17 00:00:00 2001
|
|
|
6ed69d |
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
|
6ed69d |
Date: Mon, 10 Jun 2019 09:25:05 -0700
|
|
|
6ed69d |
Subject: [PATCH 08/11] CVE-2019-7575: Fix a buffer overwrite in
|
|
|
6ed69d |
MS_ADPCM_decode If a WAV format defines shorter audio stream and decoded MS
|
|
|
6ed69d |
ADPCM data chunk is longer, decoding continued past the output audio buffer.
|
|
|
6ed69d |
MIME-Version: 1.0
|
|
|
6ed69d |
Content-Type: text/plain; charset=UTF-8
|
|
|
6ed69d |
Content-Transfer-Encoding: 8bit
|
|
|
6ed69d |
|
|
|
6ed69d |
This fix is based on a patch from
|
|
|
6ed69d |
<https://bugzilla.libsdl.org/show_bug.cgi?id=4492>.
|
|
|
6ed69d |
|
|
|
6ed69d |
https://bugzilla.libsdl.org/show_bug.cgi?id=4493
|
|
|
6ed69d |
CVE-2019-7575
|
|
|
6ed69d |
|
|
|
6ed69d |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
6ed69d |
|
|
|
6ed69d |
--HG--
|
|
|
6ed69d |
branch : SDL-1.2
|
|
|
6ed69d |
---
|
|
|
6ed69d |
src/audio/SDL_wave.c | 13 ++++++++-----
|
|
|
6ed69d |
1 file changed, 8 insertions(+), 5 deletions(-)
|
|
|
6ed69d |
|
|
|
6ed69d |
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
|
|
|
6ed69d |
index 88ac2cca6..5f9365147 100644
|
|
|
6ed69d |
--- a/src/audio/SDL_wave.c
|
|
|
6ed69d |
+++ b/src/audio/SDL_wave.c
|
|
|
6ed69d |
@@ -122,7 +122,7 @@ static Sint32 MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
|
|
|
6ed69d |
static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|
|
6ed69d |
{
|
|
|
6ed69d |
struct MS_ADPCM_decodestate *state[2];
|
|
|
6ed69d |
- Uint8 *freeable, *encoded, *encoded_end, *decoded;
|
|
|
6ed69d |
+ Uint8 *freeable, *encoded, *encoded_end, *decoded, *decoded_end;
|
|
|
6ed69d |
Sint32 encoded_len, samplesleft;
|
|
|
6ed69d |
Sint8 nybble, stereo;
|
|
|
6ed69d |
Sint16 *coeff[2];
|
|
|
6ed69d |
@@ -142,6 +142,7 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|
|
6ed69d |
return(-1);
|
|
|
6ed69d |
}
|
|
|
6ed69d |
decoded = *audio_buf;
|
|
|
6ed69d |
+ decoded_end = decoded + *audio_len;
|
|
|
6ed69d |
|
|
|
6ed69d |
/* Get ready... Go! */
|
|
|
6ed69d |
stereo = (MS_ADPCM_state.wavefmt.channels == 2);
|
|
|
6ed69d |
@@ -149,7 +150,7 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|
|
6ed69d |
state[1] = &MS_ADPCM_state.state[stereo];
|
|
|
6ed69d |
while ( encoded_len >= MS_ADPCM_state.wavefmt.blockalign ) {
|
|
|
6ed69d |
/* Grab the initial information for this block */
|
|
|
6ed69d |
- if (encoded + 7 + (stereo ? 7 : 0) > encoded_end) goto too_short;
|
|
|
6ed69d |
+ if (encoded + 7 + (stereo ? 7 : 0) > encoded_end) goto invalid_size;
|
|
|
6ed69d |
state[0]->hPredictor = *encoded++;
|
|
|
6ed69d |
if ( stereo ) {
|
|
|
6ed69d |
state[1]->hPredictor = *encoded++;
|
|
|
6ed69d |
@@ -179,6 +180,7 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|
|
6ed69d |
coeff[1] = MS_ADPCM_state.aCoeff[state[1]->hPredictor];
|
|
|
6ed69d |
|
|
|
6ed69d |
/* Store the two initial samples we start with */
|
|
|
6ed69d |
+ if (decoded + 4 + (stereo ? 4 : 0) > decoded_end) goto invalid_size;
|
|
|
6ed69d |
decoded[0] = state[0]->iSamp2&0xFF;
|
|
|
6ed69d |
decoded[1] = state[0]->iSamp2>>8;
|
|
|
6ed69d |
decoded += 2;
|
|
|
6ed69d |
@@ -200,7 +202,8 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|
|
6ed69d |
samplesleft = (MS_ADPCM_state.wSamplesPerBlock-2)*
|
|
|
6ed69d |
MS_ADPCM_state.wavefmt.channels;
|
|
|
6ed69d |
while ( samplesleft > 0 ) {
|
|
|
6ed69d |
- if (encoded + 1 > encoded_end) goto too_short;
|
|
|
6ed69d |
+ if (encoded + 1 > encoded_end) goto invalid_size;
|
|
|
6ed69d |
+ if (decoded + 4 > decoded_end) goto invalid_size;
|
|
|
6ed69d |
|
|
|
6ed69d |
nybble = (*encoded)>>4;
|
|
|
6ed69d |
new_sample = MS_ADPCM_nibble(state[0],nybble,coeff[0]);
|
|
|
6ed69d |
@@ -223,8 +226,8 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
|
|
6ed69d |
}
|
|
|
6ed69d |
SDL_free(freeable);
|
|
|
6ed69d |
return(0);
|
|
|
6ed69d |
-too_short:
|
|
|
6ed69d |
- SDL_SetError("Too short chunk for a MS ADPCM decoder");
|
|
|
6ed69d |
+invalid_size:
|
|
|
6ed69d |
+ SDL_SetError("Unexpected chunk length for a MS ADPCM decoder");
|
|
|
6ed69d |
SDL_free(freeable);
|
|
|
6ed69d |
return(-1);
|
|
|
6ed69d |
invalid_predictor:
|
|
|
6ed69d |
--
|
|
|
6ed69d |
2.21.0
|
|
|
6ed69d |
|