Reject high num_samples to prevent giant wavs in CLI with bad files

This commit is contained in:
bnnm 2019-12-05 23:20:16 +01:00
parent 30ee4129d1
commit 0f84ce5e77
2 changed files with 3 additions and 2 deletions

View File

@ -514,8 +514,8 @@ static VGMSTREAM * init_vgmstream_internal(STREAMFILE *streamFile) {
if (!vgmstream)
continue;
/* fail if there is nothing to play (without this check vgmstream can generate empty files) */
if (vgmstream->num_samples <= 0) {
/* fail if there is nothing/too much to play (<=0 generates empty files, >N writes GBs of garbage) */
if (vgmstream->num_samples <= 0 || vgmstream->num_samples > VGMSTREAM_MAX_NUM_SAMPLES) {
VGM_LOG("VGMSTREAM: wrong num_samples %i\n", vgmstream->num_samples);
close_vgmstream(vgmstream);
continue;

View File

@ -12,6 +12,7 @@ enum { VGMSTREAM_MAX_CHANNELS = 64 };
enum { VGMSTREAM_MIN_SAMPLE_RATE = 300 }; /* 300 is Wwise min */
enum { VGMSTREAM_MAX_SAMPLE_RATE = 192000 }; /* found in some FSB5 */
enum { VGMSTREAM_MAX_SUBSONGS = 65535 };
enum { VGMSTREAM_MAX_NUM_SAMPLES = 1000000000 }; /* no ~5h vgm hopefully */
#include "streamfile.h"