Make sure read_m3u won't read past the end of the buffer, causing a crash
This commit is contained in:
parent
88b5205135
commit
f5c21d249c
|
@ -3,6 +3,7 @@ D1X-Rebirth Changelog
|
|||
20101113
|
||||
--------
|
||||
main/playsave.c: In plyr_save_stats setting filename to size of PATH_MAX to have enough space to also hold the player directory prefix which would otherwise create a memory corruption and crash the game
|
||||
arch/sdl/jukebox.c: Make sure read_m3u won't read past the end of the buffer, causing a crash
|
||||
|
||||
20101109
|
||||
--------
|
||||
|
|
|
@ -59,7 +59,7 @@ int mix_play_file(char *filename, int loop, void (*hook_finished_track)())
|
|||
if (!current_music)
|
||||
current_music = Mix_LoadMUS(filename);
|
||||
|
||||
// no luck. so it might be in Searchpath. So try to build absolute path
|
||||
// no luck. so either it's in an archive or Searchpath
|
||||
if (!current_music)
|
||||
{
|
||||
PHYSFSX_getRealPath(filename, full_path);
|
||||
|
@ -68,18 +68,15 @@ int mix_play_file(char *filename, int loop, void (*hook_finished_track)())
|
|||
filename = full_path; // used later for possible error reporting
|
||||
}
|
||||
|
||||
// still nothin'? Let's open via PhysFS in case it's located inside an archive
|
||||
if (!current_music)
|
||||
{
|
||||
filehandle = PHYSFS_openRead(filename);
|
||||
if (filehandle != NULL)
|
||||
{
|
||||
current_music_hndlbuf = d_realloc(current_music_hndlbuf, sizeof(char *)*PHYSFS_fileLength(filehandle));
|
||||
bufsize = PHYSFS_read(filehandle, current_music_hndlbuf, sizeof(char), PHYSFS_fileLength(filehandle));
|
||||
rw = SDL_RWFromConstMem(current_music_hndlbuf,bufsize*sizeof(char));
|
||||
PHYSFS_close(filehandle);
|
||||
current_music = Mix_LoadMUS_RW(rw);
|
||||
}
|
||||
if (filehandle != NULL)
|
||||
{
|
||||
current_music_hndlbuf = d_realloc(current_music_hndlbuf, sizeof(char *)*PHYSFS_fileLength(filehandle));
|
||||
bufsize = PHYSFS_read(filehandle, current_music_hndlbuf, sizeof(char), PHYSFS_fileLength(filehandle));
|
||||
rw = SDL_RWFromConstMem(current_music_hndlbuf,bufsize*sizeof(char));
|
||||
PHYSFS_close(filehandle);
|
||||
current_music = Mix_LoadMUS_RW(rw);
|
||||
}
|
||||
|
||||
if (current_music)
|
||||
|
|
|
@ -101,7 +101,7 @@ void read_m3u(void)
|
|||
JukeboxSongs.max_buf = length + 1;
|
||||
buf = JukeboxSongs.list_buf;
|
||||
|
||||
while (buf < JukeboxSongs.list_buf + length)
|
||||
while (buf < JukeboxSongs.list_buf + length - 1)
|
||||
{
|
||||
while (*buf == 0 || *buf == 10 || *buf == 13) // find new line - support DOS, Unix and Mac line endings
|
||||
buf++;
|
||||
|
|
Loading…
Reference in a new issue