From 5cae4cbaa98f4f978a5c84ab48d358abd7a7f1f1 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sun, 3 Dec 2023 23:45:48 +0100 Subject: [PATCH] awc: fixes --- src/meta/awc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/meta/awc.c b/src/meta/awc.c index 52035217..8f46adc9 100644 --- a/src/meta/awc.c +++ b/src/meta/awc.c @@ -24,6 +24,7 @@ typedef struct { uint32_t stream_size; uint32_t vorbis_offset[AWC_MAX_MUSIC_CHANNELS]; + /* stream+music only */ uint32_t channel_hash[AWC_MAX_MUSIC_CHANNELS]; struct { uint32_t hash_id; @@ -274,7 +275,7 @@ static int parse_awc_header(STREAMFILE* sf, awc_header* awc) { //if (flags % 0x00020000) // awc->is_unordered = 1; - /* stream/multichannel flag (GTA5 only) */ + /* stream/multichannel flag (rare, GTA5/RDR2) */ //if (flags % 0x00040000) // awc->is_multichannel = 1; @@ -322,6 +323,9 @@ static int parse_awc_header(STREAMFILE* sf, awc_header* awc) { if (awc->is_streamed) { /* music with N channels, other streams aren't used ignored */ awc->total_subsongs = 1; target_subsong = 1; + /* array access below */ + if (entries >= AWC_MAX_MUSIC_CHANNELS) + goto fail; } else { /* sfx pack, each stream is a sound */ awc->total_subsongs = entries;