Bug 441446

Summary: Copying file from FAT32 triggeres endless loop in file.so
Product: [Frameworks and Libraries] frameworks-kio Reporter: Oliver Freyermuth <o.freyermuth>
Component: generalAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kdelibs-bugs, nate
Priority: NOR    
Version: 5.82.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description Oliver Freyermuth 2021-08-23 18:50:47 UTC
SUMMARY
Copying any file from a FAT32 file system triggers an endless loop at the end of the copy operation in file.so for me.

STEPS TO REPRODUCE
1. Copy any file from a FAT32 FS to e.g. btrfs, using for example Dolphin to trigger use of kio / file.so plugin. 
2. Observe endless loop. 

OBSERVED RESULT
Endless loop. 

EXPECTED RESULT
Copy operation to finish. 

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Gentoo Linux, 5.9.11 kernel
(available in About System)
KDE Plasma Version: 5.21.5
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
I did some debugging, and found things get stuck in the outer of the two while loops around here:
https://github.com/KDE/kio/blob/0b4fd24f66656265c531fe1fe97e23e388c7cab2/src/ioslaves/file/file_unix.cpp#L669

Using "gdb", I find that fgetxattr returns -1, and errno is set to EOPNOTSUPP, so valuelen is -1, when the attribute "security.selinux" is queried. 

The problem appears to be that the comment in:
https://github.com/KDE/kio/blob/0b4fd24f66656265c531fe1fe97e23e388c7cab2/src/ioslaves/file/file_unix.cpp#L676
says "Some other error, skip to the next attribute", but this actually never happens, since:
https://github.com/KDE/kio/blob/0b4fd24f66656265c531fe1fe97e23e388c7cab2/src/ioslaves/file/file_unix.cpp#L681
jumps back to the beginning of the outer while loop without skipping to the next key.
Comment 1 Bug Janitor Service 2021-09-09 21:06:37 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/573
Comment 2 Méven Car 2021-10-06 16:17:30 UTC
Git commit d4e0b6223cdc740a75b001badd09aded41a89723 by Méven Car, on behalf of Oliver Freyermuth.
Committed on 06/10/2021 at 16:12.
Pushed by meven into branch 'master'.

file_unix: Fix endless loop during xattr copy.

If an attribute can not be read e.g. due to ENOTSUP,
skip the attribute instead of looping endlessly.

M  +5    -5    src/ioslaves/file/file_unix.cpp

https://invent.kde.org/frameworks/kio/commit/d4e0b6223cdc740a75b001badd09aded41a89723