Blame SOURCES/0001-CVE-2019-7572-Fix-a-buffer-overread-in-IMA_ADPCM_nib.patch

cfd472
From 4b4cac39ba7988df9d8def32360dd842b707ba74 Mon Sep 17 00:00:00 2001
cfd472
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
cfd472
Date: Sat, 8 Jun 2019 17:57:43 -0700
cfd472
Subject: [PATCH 01/11] CVE-2019-7572: Fix a buffer overread in
cfd472
 IMA_ADPCM_nibble If an IMA ADPCM block contained an initial index out of step
cfd472
 table range (loaded in IMA_ADPCM_decode()), IMA_ADPCM_nibble() blindly used
cfd472
 this bogus value and that lead to a buffer overread.
cfd472
MIME-Version: 1.0
cfd472
Content-Type: text/plain; charset=UTF-8
cfd472
Content-Transfer-Encoding: 8bit
cfd472
cfd472
This patch fixes it by moving clamping the index value at the
cfd472
beginning of IMA_ADPCM_nibble() function instead of the end after
cfd472
an update.
cfd472
cfd472
CVE-2019-7572
cfd472
https://bugzilla.libsdl.org/show_bug.cgi?id=4495
cfd472
cfd472
Signed-off-by: Petr Písař <ppisar@redhat.com>
cfd472
cfd472
--HG--
cfd472
branch : SDL-1.2
cfd472
---
cfd472
 src/audio/SDL_wave.c | 14 ++++++++------
cfd472
 1 file changed, 8 insertions(+), 6 deletions(-)
cfd472
cfd472
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
cfd472
index b4ad6c787..ba1fb5252 100644
cfd472
--- a/src/audio/SDL_wave.c
cfd472
+++ b/src/audio/SDL_wave.c
cfd472
@@ -264,6 +264,14 @@ static Sint32 IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state,Uint8 nybble)
cfd472
 	};
cfd472
 	Sint32 delta, step;
cfd472
 
cfd472
+	/* Clamp index value. The inital value can be invalid. */
cfd472
+	if ( state->index > 88 ) {
cfd472
+		state->index = 88;
cfd472
+	} else
cfd472
+	if ( state->index < 0 ) {
cfd472
+		state->index = 0;
cfd472
+	}
cfd472
+
cfd472
 	/* Compute difference and new sample value */
cfd472
 	step = step_table[state->index];
cfd472
 	delta = step >> 3;
cfd472
@@ -275,12 +283,6 @@ static Sint32 IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state,Uint8 nybble)
cfd472
 
cfd472
 	/* Update index value */
cfd472
 	state->index += index_table[nybble];
cfd472
-	if ( state->index > 88 ) {
cfd472
-		state->index = 88;
cfd472
-	} else
cfd472
-	if ( state->index < 0 ) {
cfd472
-		state->index = 0;
cfd472
-	}
cfd472
 
cfd472
 	/* Clamp output sample */
cfd472
 	if ( state->sample > max_audioval ) {
cfd472
-- 
cfd472
2.21.0
cfd472