From 5fdb71dbb1e7fdfb6ae35254c44df344d49df4c7 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 31 Dec 2022 17:05:43 +0100 Subject: [PATCH] Reject wrong RWSD and lower priority --- src/meta/rwsd.c | 6 ++++++ src/vgmstream.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/meta/rwsd.c b/src/meta/rwsd.c index f4a0a248..a8078261 100644 --- a/src/meta/rwsd.c +++ b/src/meta/rwsd.c @@ -106,6 +106,12 @@ VGMSTREAM* init_vgmstream_rwsd(STREAMFILE* sf) { stream_size = read_32bitBE(wave_offset + 0x50,sf); + /* this meta is a hack as WSD is just note info, and data offsets are elsewhere in the brsar, + * while this assumes whatever data follows RWSD must belong to it (common but fails in Wii Sports), + * detect data excess and reject (probably should use brawlbox's info offsets) */ + if (stream_size * channels + 0x10000 < get_streamfile_size(sf) - start_offset) + goto fail; + /* open the file for reading by each channel */ { int i; diff --git a/src/vgmstream.c b/src/vgmstream.c index 3121e0a4..e0675412 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -38,7 +38,6 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = { init_vgmstream_gcsw, init_vgmstream_ads, init_vgmstream_nps, - init_vgmstream_rwsd, init_vgmstream_xa, init_vgmstream_rxws, init_vgmstream_ngc_dsp_stm, @@ -542,10 +541,10 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = { /* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */ init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */ - init_vgmstream_dtk, + init_vgmstream_dtk, /* semi-raw GC streamed files */ init_vgmstream_mpeg, /* semi-raw MP3 */ - init_vgmstream_encrypted, /* encrypted stuff */ init_vgmstream_btsnd, /* semi-headerless */ + init_vgmstream_encrypted, /* encrypted stuff */ init_vgmstream_raw_int, /* .int raw PCM */ init_vgmstream_ps_headerless, /* tries to detect a bunch of PS-ADPCM formats */ init_vgmstream_raw_snds, /* .snds raw SNDS IMA */ @@ -560,6 +559,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = { init_vgmstream_ps2_adm, /* weird non-constant PSX blocks */ init_vgmstream_baf_badrip, /* crap, to be removed */ init_vgmstream_rxws_badrip, /* crap, to be removed */ + init_vgmstream_rwsd, /* crap, to be removed */ #ifdef VGM_USE_FFMPEG init_vgmstream_ffmpeg, /* may play anything incorrectly, since FFmpeg doesn't check extensions */ #endif