Skip to content

Fix error when both pregap in index 0 are present#7

Merged
aperezbios merged 1 commit intomainfrom
fix/file-offset-error
Mar 6, 2026
Merged

Fix error when both pregap in index 0 are present#7
aperezbios merged 1 commit intomainfrom
fix/file-offset-error

Conversation

@morio
Copy link
Collaborator

@morio morio commented Mar 6, 2026

The ZuluIDE was failing reads on audio tracks with a bin/cue pair that had a second track that had both a pregap (unstored pregap) and and index 0 entries. The unstored pregap length was longer than the
index1 time - index0 time (stored pregap) length.

Here is the example file:

FILE "TestFile.bin" BINARY
  TRACK 01 MODE1/2352
    INDEX 01 00:00:00
  TRACK 02 AUDIO
    PREGAP 00:02:00
    INDEX 00 29:09:48
    INDEX 01 29:10:48

This caused file_offset calculation in the parser to be a negative int32_t number inside a uint64_t which then caused a seek error because the file offset was past the end of the file.

The solution here is to remove the unstored pregap from the stored pregap calculation and apply it to the file offset only if there is both an index0 and index1 in the track entry.

A test for this case was added to the test program.

The ZuluIDE was failing reads on audio tracks with a bin/cue pair that
had a second track that had both a pregap (unstored pregap) and and
index 0 entries. The unstored pregap length was longer than the
 index1 time - index0 time (stored pregap) length.

Here is the example file:
```
FILE "TestFile.bin" BINARY
  TRACK 01 MODE1/2352
    INDEX 01 00:00:00
  TRACK 02 AUDIO
    PREGAP 00:02:00
    INDEX 00 29:09:48
    INDEX 01 29:10:48
```

This caused file_offset calculation in the parser to be a negative
int32_t number inside a uint64_t which then caused a seek error because
the file offset was passed the end of the file.

The solution here is to remove the unstored pregap from the
stored pregap calculation and apply it to the file offset only if
there is both an index0 and index1 in the track entry.

A test for this case was added to the test program.
@morio morio marked this pull request as draft March 6, 2026 00:28
@morio morio requested a review from PetteriAimonen March 6, 2026 00:28
@morio
Copy link
Collaborator Author

morio commented Mar 6, 2026

@PetteriAimonen does this seem correct?

@morio morio marked this pull request as ready for review March 6, 2026 00:29
Copy link
Collaborator

@PetteriAimonen PetteriAimonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@aperezbios aperezbios merged commit a3462e9 into main Mar 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants