Skip to content

Commit

Permalink
libhfs: permit nonexistent attributes file when listing xattrs
Browse files Browse the repository at this point in the history
The HFS+ attributes file need not exist if no xattrs have been written
on a given volume. In this case hfslib_find_attribute_records_for_cnid
now responds that it successfully found no attributes rather than
considering this an error.

Fixes spurious ENOATTR results when listing built-in extended attributes
like com.apple.FinderInfo on volumes with no attributes file.
  • Loading branch information
0x09 committed Apr 18, 2024
1 parent 49029ed commit 1c238e9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/libhfs/libhfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,11 +1196,14 @@ hfslib_find_attribute_records_for_cnid(hfs_volume* in_vol, hfs_cnid_t cnid,
node = NULL;
nd.num_recs = 0;

/* Not all volumes have an attributes file */
/*
* Not all volumes have an attributes file. this is not an error, but
* out_num_attrs will be zero.
*/
if (in_vol->vh.attributes_file.extents[0].block_count == 0 ||
in_vol->ahr.leaf_recs == 0 ||
in_vol->ahr.tree_depth == 0)
return 1;
return 0;

curkey = hfslib_malloc(sizeof(hfs_attribute_key_t), cbargs);
if (curkey == NULL)
Expand Down

0 comments on commit 1c238e9

Please sign in to comment.