From b88e71a8657f29751b861d0b83f2e865ec73d9dd Mon Sep 17 00:00:00 2001 From: Kevin Bortis Date: Tue, 31 Mar 2026 19:40:47 +0200 Subject: [PATCH] fix Mode 2 form detection in errored-suffix read path --- src/read.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/read.c b/src/read.c index ef8c196..4f95c26 100644 --- a/src/read.c +++ b/src/read.c @@ -1855,8 +1855,8 @@ AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_long(void *context, const uint64 else { // Mode 2 where ECC/EDC failed — restore user data + stored suffix. - // Check subheader (already copied to data+16) to determine form. - if(data[0x12] & 0x20) + // Check both subheader copies to match write path form detection. + if((data[0x12] & 0x20) || (data[0x16] & 0x20)) { // Form 2: 2324 bytes user data, 4 bytes EDC suffix memcpy(data + 24, bare_data, 2324); @@ -1893,9 +1893,10 @@ AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_long(void *context, const uint64 else { // Mode 2 where ECC/EDC failed — restore user data + stored suffix. + // Check both subheader copies to match write path form detection. const uint32_t sfx_index = (ctx->sector_suffix_ddt[corrected_sector_address] & CD_DFIX_MASK) - 1; - if(data[0x12] & 0x20) + if((data[0x12] & 0x20) || (data[0x16] & 0x20)) { memcpy(data + 24, bare_data, 2324); memcpy(data + 2348, ctx->sector_suffix_corrected + sfx_index * 288, 4);