85 lines
2.8 KiB
Diff
85 lines
2.8 KiB
Diff
|
From 45ef356d8c01a3941286b35b90eb319959f20f2c 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 09:06:23 -0700
|
||
|
Subject: [PATCH 07/11] CVE-2019-7573, CVE-2019-7576: Fix buffer overreads in
|
||
|
InitMS_ADPCM If MS ADPCM format chunk was too short, InitMS_ADPCM() parsing
|
||
|
it could read past the end of chunk data. This patch fixes it.
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
CVE-2019-7573
|
||
|
https://bugzilla.libsdl.org/show_bug.cgi?id=4491
|
||
|
CVE-2019-7576
|
||
|
https://bugzilla.libsdl.org/show_bug.cgi?id=4490
|
||
|
|
||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||
|
|
||
|
--HG--
|
||
|
branch : SDL-1.2
|
||
|
---
|
||
|
src/audio/SDL_wave.c | 13 ++++++++++---
|
||
|
1 file changed, 10 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
|
||
|
index 4159eb710..88ac2cca6 100644
|
||
|
--- a/src/audio/SDL_wave.c
|
||
|
+++ b/src/audio/SDL_wave.c
|
||
|
@@ -44,12 +44,13 @@ static struct MS_ADPCM_decoder {
|
||
|
struct MS_ADPCM_decodestate state[2];
|
||
|
} MS_ADPCM_state;
|
||
|
|
||
|
-static int InitMS_ADPCM(WaveFMT *format)
|
||
|
+static int InitMS_ADPCM(WaveFMT *format, int length)
|
||
|
{
|
||
|
- Uint8 *rogue_feel;
|
||
|
+ Uint8 *rogue_feel, *rogue_feel_end;
|
||
|
int i;
|
||
|
|
||
|
/* Set the rogue pointer to the MS_ADPCM specific data */
|
||
|
+ if (length < sizeof(*format)) goto too_short;
|
||
|
MS_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
|
||
|
MS_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
|
||
|
MS_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
|
||
|
@@ -58,9 +59,11 @@ static int InitMS_ADPCM(WaveFMT *format)
|
||
|
MS_ADPCM_state.wavefmt.bitspersample =
|
||
|
SDL_SwapLE16(format->bitspersample);
|
||
|
rogue_feel = (Uint8 *)format+sizeof(*format);
|
||
|
+ rogue_feel_end = (Uint8 *)format + length;
|
||
|
if ( sizeof(*format) == 16 ) {
|
||
|
rogue_feel += sizeof(Uint16);
|
||
|
}
|
||
|
+ if (rogue_feel + 4 > rogue_feel_end) goto too_short;
|
||
|
MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||
|
rogue_feel += sizeof(Uint16);
|
||
|
MS_ADPCM_state.wNumCoef = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||
|
@@ -70,12 +73,16 @@ static int InitMS_ADPCM(WaveFMT *format)
|
||
|
return(-1);
|
||
|
}
|
||
|
for ( i=0; i<MS_ADPCM_state.wNumCoef; ++i ) {
|
||
|
+ if (rogue_feel + 4 > rogue_feel_end) goto too_short;
|
||
|
MS_ADPCM_state.aCoeff[i][0] = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||
|
rogue_feel += sizeof(Uint16);
|
||
|
MS_ADPCM_state.aCoeff[i][1] = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||
|
rogue_feel += sizeof(Uint16);
|
||
|
}
|
||
|
return(0);
|
||
|
+too_short:
|
||
|
+ SDL_SetError("Unexpected length of a chunk with a MS ADPCM format");
|
||
|
+ return(-1);
|
||
|
}
|
||
|
|
||
|
static Sint32 MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
|
||
|
@@ -495,7 +502,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
|
||
|
break;
|
||
|
case MS_ADPCM_CODE:
|
||
|
/* Try to understand this */
|
||
|
- if ( InitMS_ADPCM(format) < 0 ) {
|
||
|
+ if ( InitMS_ADPCM(format, lenread) < 0 ) {
|
||
|
was_error = 1;
|
||
|
goto done;
|
||
|
}
|
||
|
--
|
||
|
2.21.0
|
||
|
|