Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad test for end of DOS T/S list #59

Closed
fadden opened this issue Mar 11, 2023 · 0 comments
Closed

Bad test for end of DOS T/S list #59

fadden opened this issue Mar 11, 2023 · 0 comments
Labels

Comments

@fadden
Copy link
Owner

fadden commented Mar 11, 2023

DOS33.cpp's LoadTSList() function does this:

    if (track != 0 && sector != 0) {
        /* more T/S lists to come, so we keep all entries */
        tsCount += kMaxTSPairs;
    } else {
        /* this was the last one */

When it actually wanted to do:

    if (track != 0) {

The existing code thinks it has reached the end of all T/S lists when the sector number of the next T/S link is zero. As a result, if you have a file large enough to require at least 3 T/S lists, and one of the early T/S lists happens to live in sector 0 of a track, the T/S extractor will have a shortened count.

It doesn't actually stop copying entries into the output array, it just uses the wrong value for the count. The count is used to set the output array position, so the later entries overwrite the earlier entries in the array, and you end up losing a 122*256-byte chunk out of the middle of the file.

Sample image that demonstrates the issue with a sparse text file: cp-ts-bug.zip

@fadden fadden added the bug label Mar 11, 2023
fadden added a commit that referenced this issue Mar 11, 2023
Only affects a small percentage of very large or sparse files.

(issue #59)
@fadden fadden closed this as completed Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant