From 611e5568094c61c06a8b4c5c74b6ab6cecea7def Mon Sep 17 00:00:00 2001 From: bnnm Date: Thu, 16 Aug 2018 20:05:53 +0200 Subject: [PATCH] Reject files with incorrect num_streams --- src/vgmstream.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/vgmstream.c b/src/vgmstream.c index fd533350..d3d9343f 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -503,6 +503,14 @@ static VGMSTREAM * init_vgmstream_internal(STREAMFILE *streamFile) { } #endif + /* files can have thousands subsongs, but let's put a limit */ + if (vgmstream->num_streams < 0 || vgmstream->num_streams > 65535) { + VGM_LOG("VGMSTREAM: wrong num_streams (ns=%i)\n", vgmstream->num_streams); + close_vgmstream(vgmstream); + continue; + } + + /* save info */ /* stream_index 0 may be used by plugins to signal "vgmstream default" (IOW don't force to 1) */ if (!vgmstream->stream_index)