Skip to content

hfs: fix catalog scans and header validation - #25

Merged
reinauer merged 2 commits into
mainfrom
hfs-catalog-scan-fixes
Oct 31, 2026
Merged

reinauer merged 2 commits into
mainfrom
hfs-catalog-scan-fixes

Conversation

@reinauer

Copy link
Copy Markdown
Owner

Two HFS catalog bugs made discs list incompletely or fail to mount as HFS.

  • hfs: start directory scans at the first matching leaf: the catalog descent followed the last index key at or below the directory's parent CNID, so entries before the last leaf were skipped once the catalog spanned several leaf nodes. A test HFS+ disc listed 9 of 402 root entries. Fixed in both the HFS and HFS+ backends, with a multi-leaf HFS+ fixture.
  • hfs: read the catalog header before validating it: the header was read while cat_node_size was still zero, so the check ran on an uninitialized stack buffer. Pure HFS discs were rejected and hybrid discs fell back to ISO 9660, which hid the bug because the names match. The tests now check real HFS names and cover a disc with no ISO 9660 side.

These are cherry-picked onto main from hfs-catalog-fixes, without the regparm and README commits on that branch.

Tested with make check and make golden-check (58 format tests passed; the real AS fixture was skipped because it is unavailable).

The catalog descent followed the last index key whose parent CNID was
not greater than the directory being listed. All of a directory's
records except those in that last leaf were skipped, so a listing lost
most of its entries once the catalog spanned several leaf nodes. A test
HFS+ disc listed 9 of 402 root entries.

Follow the last key before the directory instead, which can lead to the
leaf holding its first records, in both the HFS and HFS+ backends. Add a
multi-leaf HFS+ fixture.
The catalog header was read while cat_node_size was still zero, so
hfs_read_node() copied nothing and the header check ran on an
uninitialized stack buffer. The mount failed, pure HFS discs were
rejected, and hybrid discs fell back to their ISO 9660 view. The HFS
tests passed against that fallback because its names match.

Set the node size to the header size for that read. Check the real HFS
names in the existing tests, and test a disc with no ISO 9660 side.
@reinauer
reinauer merged commit 9fcd05b into main Oct 31, 2026
2 checks 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.

1 participant