Repository navigation
Conversation
The track getters shared by the bincue, cdrdao and NRG drivers (channels, copy permit, pre-emphasis, pregap and ISRC) used the track number as an index into the table of tracks without checking it. The public wrappers only check it against the last track, or not at all, so a disc whose first track is 99 read tocent[-98] for track 1. Check that the track is between the first and the last track, and return the getter's error value otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A track number that didn't follow the previous one was only logged, and the tracks were still numbered from the first one. A cue sheet with tracks 99, 2 and 3 gave a disc whose last track is 101, past the 99 tracks a CD can have and that callers size their tables for; track 170 would be taken for the lead-out. Make it an error, also when only checking whether a file is a cue sheet. Since each track number is at most 99, so is the last one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bincue: the BIN file named by FILE replaced the "source" argument set when the image is opened without freeing it, on every successful open. A second FILE in a track, CATALOG or ISRC leaked the first value too. nrg: a second DAOX or DAOI chunk leaked the MCN and the tracks' ISRCs, and a second CDTX chunk the first CD-TEXT. A failed MCN allocation leaked the footer buffer, and a failed ISRC allocation wasn't checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A second FILE, AUDIOFILE or DATAFILE in a track leaked the first file name and left the first file open, and a second CATALOG or ISRC leaked the first value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The number of tracks was only set once the whole file had parsed, so when a later line failed, the cleanup freed none of the earlier tracks' file names, ISRCs and open files. Set it on the error path too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bincue: the track getters on a disc whose only track is 99, tracks whose numbers don't follow each other, and CATALOG, FILE and ISRC given twice. cdrdao: CATALOG, ISRC and FILE/DATAFILE given twice, and a TOC file that fails after its first track. The leaks these used to cause only show under a memory checker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes in the bincue, cdrdao and NRG image drivers for track numbers and for values that were leaked.
Track numbers
tocent[-98]for track 1. They now return their error value for a track the image doesn't have.Leaks
Every freed value is replaced right away or freed once on close; the repeated keywords and failure paths were run under ASan to check for double frees.
Tests
New checks in
test/driver/bincue.candtest/driver/cdrdao.c. With the old code the bincue test crashes in the track getters; the leaks only show under a memory checker.make checkpasses, and the bincue, cdrdao and nrg driver tests are clean under valgrind.🤖 Generated with Claude Code