Skip to content

A sample payload whose header disagrees with its directory entry is extracted silently #23

Description

@bmxcode

Found while settling #17, and not worked on there.

Every AKAI sample payload begins with a 150-byte header that repeats the file's name at offset 3. The directory entry gives the same name. Nothing compares them, and where they disagree the file extracts anyway — as a WAV that opens, plays, and is somebody else's audio.

Where it bites

AMG - Kickin' Lunatic Beats 2 AKAI CD1.mdx yields 669 files. Nine of them are wrong:

block 4449 '094AIRBEA6-R'  payload header: id=179 valid=0x03 name unreadable rate=1734
block 4513 '094AIRBEA7-L'  payload header: id=4   valid=0x15 name unreadable rate=4052
block 4541 '094AIRBEA7-R'  payload header: id=116 valid=0x19 name unreadable rate=3677
...  9 in total, all in volume '13-TRACK 06', all past block 4449

The cause is that image, not those files — it is short of the disc it was made from by four 32 KB blocks, so everything past the first gap has slid (#17, ADR-0022). The point here is that nothing noticed. id is not 1 or 3, valid is not 0x80, the name does not decode, and the rate is 1734 Hz; all four are visible for free at the moment the payload is read, and all four were ignored.

A rate of 1734 is the loudest of them. No sampler wrote that, and it goes into a WAV header unchallenged.

What a check would look like

At parse_sample time, for a file the directory calls a sample:

  • payload[0] is 3 (or 1 for a program);
  • payload[15] is 0x80;
  • decode_name(payload[3:15]) equals the directory's name;
  • the rate at 138 is one the format doc lists — 44 100, 22 050, 33 075, 29 400, 48 000 are what 380 reference samples use.

The interesting question is what to do on a mismatch, and it is not obvious. Refusing the file loses audio that may be perfectly good with a wrong name; extracting it silently is what happens now. Skip-and-log is the house style for damaged input, and this is damaged input — but it needs measuring across the collection first, because a mismatch may be commoner than these nine and some of it may be benign.

Measure before deciding

The sweep behind these numbers checked the name only. Across the 44 AKAI discs, run all four tests and count: how many files fail, on how many discs, and whether the failures cluster the way these do — at the tail of one volume, on an image with an established gap — or scatter, which would mean the check is wrong rather than the discs.

Discs needed

AMG - Kickin' Lunatic Beats 2 AKAI CD1.mdx for the nine known bad files; the rest of the AKAI collection for the false-positive rate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions