Skip to content

Incorrect header in wav files can lead to enormous memory allocations (+4gb) #10052

Open
@ChichiMsdk

Description

@ChichiMsdk

When loading a wav file using SDL_LoadWAV(fname, &spec, &audio_buf, &wav_length), an incorrect header that reports an arbitrary amount of data could lead to several gb of allocations performed on the audio_buf
Despite knowing the correct size of the audio file since it is correctly returned by wav_length

In my case the file was around 70mb and reported it's size of -1 and therefore SDL allocated the signed int max 32bits value (+4gb !)

EDIT: I also modified the wav file manually and replaced to number by something close to reality (80mb) and the allocation varied accordingly btw

I guess we should instead allocate the correct amount by checking the header against the size calculated with wav_length

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions