Skip to content

Fix Solaris xattr write loop after partial write#1013

Open
AlphaGlider25 wants to merge 1 commit into
RsyncProject:masterfrom
AlphaGlider25:dev-AlphaGlider25
Open

Fix Solaris xattr write loop after partial write#1013
AlphaGlider25 wants to merge 1 commit into
RsyncProject:masterfrom
AlphaGlider25:dev-AlphaGlider25

Conversation

@AlphaGlider25

Copy link
Copy Markdown

This fixes a bug in the Solaris xattr backend's retry loop.

In lib/sysxattrs.c, the loop advances bufpos after a successful partial write, but subsequent retries continue to pass the original size value to write() rather than the remaining byte count.

As a result, if a short write occurs, the next iteration can attempt to write more bytes than remain in the source buffer.

The fix changes:

write(attrfd, (char*)value + bufpos, size);

to:

write(attrfd, (char*)value + bufpos, size - bufpos);

This matches the corresponding logic in read_xattr() and the existing retry-loop pattern used elsewhere in the file.

Notes:

  • Solaris-specific code path
  • No behavioral changes on successful full writes
  • Build and test results unchanged after the fix
  • The issue appears to date back to the initial Solaris xattr implementation

@steadytao steadytao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The size - bufpos fix seems right for the short-write case so I am happy with that but one nearby issue I noticed while reading the loop is that bufpos is a size_t so the existing bufpos = -1 failure sentinel wraps to SIZE_MAX and the final bufpos > 0 ? 0 : -1 can report success after a write failure.

Not caused by this PR but probably worth fixing in the same area as you are already touching the loop 🙂

@AlphaGlider25

AlphaGlider25 commented Jun 19, 2026

Copy link
Copy Markdown
Author

Thanks for the review.

I've fixed the issue you identified and verified the change locally. Would you like me to add the update to this PR, or is there another preferred way to submit the additional commit?

(Here is the commit link: AlphaGlider25@2a8bbb7)

@steadytao steadytao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@steadytao

Copy link
Copy Markdown
Member

Thank you, I will have a look at 1014 now!

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