Blame SOURCES/0005-CVE-2019-7577-Fix-a-buffer-overread-in-MS_ADPCM_nibb.patch

a19bfa
From 1b7d3f5e53a4d7a827ce89de22a1524bd27572f9 Mon Sep 17 00:00:00 2001
a19bfa
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
a19bfa
Date: Mon, 10 Jun 2019 08:54:29 -0700
a19bfa
Subject: [PATCH 05/11] CVE-2019-7577: Fix a buffer overread in MS_ADPCM_nibble
a19bfa
 and MS_ADPCM_decode If a chunk of RIFF/WAV file with MS ADPCM encoding
a19bfa
 contains an invalid predictor (a valid predictor's value is between 0 and 6
a19bfa
 inclusive), a buffer overread can happen when the predictor is used as an
a19bfa
 index into an array of MS ADPCM coefficients.
a19bfa
MIME-Version: 1.0
a19bfa
Content-Type: text/plain; charset=UTF-8
a19bfa
Content-Transfer-Encoding: 8bit
a19bfa
a19bfa
The overead happens when indexing MS_ADPCM_state.aCoeff[] array in
a19bfa
MS_ADPCM_decode() and later when dereferencing a coef pointer in
a19bfa
MS_ADPCM_nibble().
a19bfa
a19bfa
This patch fixes it by checking the MS ADPCM predictor values fit
a19bfa
into the valid range.
a19bfa
a19bfa
CVE-2019-7577
a19bfa
Reproducer: https://bugzilla.libsdl.org/show_bug.cgi?id=4492
a19bfa
a19bfa
Signed-off-by: Petr Písař <ppisar@redhat.com>
a19bfa
a19bfa
--HG--
a19bfa
branch : SDL-1.2
a19bfa
---
a19bfa
 src/audio/SDL_wave.c | 7 +++++++
a19bfa
 1 file changed, 7 insertions(+)
a19bfa
a19bfa
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
a19bfa
index 6c6eb14eb..3eedd20a1 100644
a19bfa
--- a/src/audio/SDL_wave.c
a19bfa
+++ b/src/audio/SDL_wave.c
a19bfa
@@ -147,6 +147,9 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
a19bfa
 		if ( stereo ) {
a19bfa
 			state[1]->hPredictor = *encoded++;
a19bfa
 		}
a19bfa
+		if (state[0]->hPredictor >= 7 || state[1]->hPredictor >= 7) {
a19bfa
+			goto invalid_predictor;
a19bfa
+		}
a19bfa
 		state[0]->iDelta = ((encoded[1]<<8)|encoded[0]);
a19bfa
 		encoded += sizeof(Sint16);
a19bfa
 		if ( stereo ) {
a19bfa
@@ -217,6 +220,10 @@ too_short:
a19bfa
 	SDL_SetError("Too short chunk for a MS ADPCM decoder");
a19bfa
 	SDL_free(freeable);
a19bfa
 	return(-1);
a19bfa
+invalid_predictor:
a19bfa
+	SDL_SetError("Invalid predictor value for a MS ADPCM decoder");
a19bfa
+	SDL_free(freeable);
a19bfa
+	return(-1);
a19bfa
 }
a19bfa
 
a19bfa
 struct IMA_ADPCM_decodestate {
a19bfa
-- 
a19bfa
2.24.1
a19bfa