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

fix: dont include xattr in extended link reading #278

Merged
merged 3 commits into from
Jan 27, 2025

Conversation

jonathongardner
Copy link
Contributor

Got an error when trying to read another squashfs file from ubuntu. Not sure if I should have created an issue first. It was raising this error. Traced it down to a symlink reading the wrong part for the xattr.

// account for the synlink target, plus 4 bytes for the xattr index after it
extra = int(binary.LittleEndian.Uint32(b[4:8])) + 4
if len(b[target:]) > extra {
s.target = string(b[8 : 8+extra])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was reading 4 bytes to much (i.e. it was reading the xattr data as part of the target)

extra = int(binary.LittleEndian.Uint32(b[4:8])) + 4
if len(b[target:]) > extra {
s.target = string(b[8 : 8+extra])
s.xAttrIndex = binary.LittleEndian.Uint32(b[8+extra : 8+extra+4])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was reading after the xattr data, so 4 bytes into the next section so it was just a random int

@@ -532,7 +532,7 @@ func (fs *FileSystem) hydrateDirectoryEntries(entries []*directoryEntryRaw) ([]*
body, header := in.getBody(), in.getHeader()
xattrIndex, has := body.xattrIndex()
xattrs := map[string]string{}
if has && xattrIndex != noXattrInodeFlag {
if has {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When i was tracing down the bug i noticed all xattrIndex already do this check or return false so i removed it

@deitch
Copy link
Collaborator

deitch commented Jan 27, 2025

Quite the catch. Thank you for tracking it down.

@deitch deitch merged commit c926038 into diskfs:master Jan 27, 2025
20 checks passed
@jonathongardner jonathongardner deleted the fix-attrs branch January 28, 2025 01:24
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.

2 participants