Skip to content

Commit 68f914a

Browse files
committedJun 10, 2019
CVE-2019-7577: Fix a buffer overread in MS_ADPCM_nibble and MS_ADPCM_decode
If a chunk of RIFF/WAV file with MS ADPCM encoding contains an invalid predictor (a valid predictor's value is between 0 and 6 inclusive), a buffer overread can happen when the predictor is used as an index into an array of MS ADPCM coefficients. The overead happens when indexing MS_ADPCM_state.aCoeff[] array in MS_ADPCM_decode() and later when dereferencing a coef pointer in MS_ADPCM_nibble(). This patch fixes it by checking the MS ADPCM predictor values fit into the valid range. CVE-2019-7577 Reproducer: https://bugzilla.libsdl.org/show_bug.cgi?id=4492 Signed-off-by: Petr P?sa? <ppisar@redhat.com>
1 parent 82e503c commit 68f914a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎src/audio/SDL_wave.c

+7
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
147147
if ( stereo ) {
148148
state[1]->hPredictor = *encoded++;
149149
}
150+
if (state[0]->hPredictor >= 7 || state[1]->hPredictor >= 7) {
151+
goto invalid_predictor;
152+
}
150153
state[0]->iDelta = ((encoded[1]<<8)|encoded[0]);
151154
encoded += sizeof(Sint16);
152155
if ( stereo ) {
@@ -217,6 +220,10 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
217220
SDL_SetError("Too short chunk for a MS ADPCM decoder");
218221
SDL_free(freeable);
219222
return(-1);
223+
invalid_predictor:
224+
SDL_SetError("Invalid predictor value for a MS ADPCM decoder");
225+
SDL_free(freeable);
226+
return(-1);
220227
}
221228

222229
struct IMA_ADPCM_decodestate {

0 commit comments

Comments
 (0)