Skip to content

Commit

Permalink
Fixed bug 2670 - Possible memory overflow in Mix_LoadWAV_RW
Browse files Browse the repository at this point in the history
Lee Salzman

In mixer.c, Mix_LoadWAV_RW, there is the following code:

        wavecvt.len = chunk->alen & ~(samplesize-1);
        wavecvt.buf = (Uint8 *)SDL_calloc(1, wavecvt.len*wavecvt.len_mult);
...
        SDL_memcpy(wavecvt.buf, chunk->abuf, chunk->alen);

That SDL_memcpy should rather be:
        SDL_memcpy(wavectf.buf, chunk->abuf, wavecvt.len);

If you imagine that wavecvt.len_mult was 1 and samplesize was greater than 1 with wavecvt.len < chunk->alen, then it may overwrite.
  • Loading branch information
slouken committed Oct 21, 2017
1 parent a9d667e commit a60d5d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mixer.c
Expand Up @@ -745,7 +745,7 @@ Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
SDL_free(chunk);
return(NULL);
}
SDL_memcpy(wavecvt.buf, chunk->abuf, chunk->alen);
SDL_memcpy(wavecvt.buf, chunk->abuf, wavecvt.len);
SDL_free(chunk->abuf);

/* Run the audio converter */
Expand Down

0 comments on commit a60d5d8

Please sign in to comment.