On 9.09.19 г. 14:32 ч., Vladimir Panteleev wrote:
> Hi Nikolay,
>
> Unfortunately, as I mentioned in the issue, I have also been unable to
> reproduce this issue locally.
>
> Please see here:
> https://github.com/kdave/btrfs-progs/issues/194
>
> The reporter tested the patch and confirmed that it worked.
> Additionally, they have provided strace output which appears to
> confirm that the bug description in the patch commit message indeed
> corresponds to the behavior they are observing on their machine.
>
> Perhaps the issue might be reproducible in an environment closer to
> the reporter's (looks like some Fedora distro judging by the uname).
Right, looking at the kernel portion listxattr just copies the attribute
names into the passed user pointer. So if the data copied is less than
XATTR_LIST_MAX then the data beyond the return value of llistxattr is
undefined which could cause the described problem.
I agree that your code is more correct as it handles data only in the
range [0...ret].
Consider this patch:
Reviewed-by: Nikolay Borisov <nbori...@suse.com>