Bug 1177947 - kio_sftp.so corrupts files when reading
Summary: kio_sftp.so corrupts files when reading
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: kde-runtime
Version: 20
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Than Ngo
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-31 14:40 UTC by Albert Flügel
Modified: 2015-01-26 02:31 UTC (History)
11 users (show)

Fixed In Version: kde-runtime-4.14.3-3.fc21
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-01-14 23:59:01 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
KDE Software Compilation 342391 0 None None None Never

Description Albert Flügel 2014-12-31 14:40:36 UTC
Description of problem:
Reading a file over sftp in dolphin corrupts it. More exactly: in the end it is nearly double as long and has repeating parts. The bug is in kio_sftp.so


Version-Release number of selected component (if applicable): 4.14.3-2.fc20


How reproducible:
Connect an Android smartphone using sftp and an sshd on the phone in dolphin.
access a file larger than 61440 bytes, e.g. a jpeg photo


Steps to Reproduce:
1. Install sshd on your android smartphone. Probably it also happens with other servers offering sftp
2. Connect in dolphin e.g. right mouse key on the left pane, select "Add Entry ..."
3. Enter sth. like sftp://<usename-on-smartphone>:<password-on-smartphone>@<your-smartphone-network-name>:<port>/ (ignore your personal security concerns regarding the password in the URL for a moment, later you can use RSA or other pubkey authentication or whatever)
4. Navigate to a JPEG image
5. open it with any picture viewer

Actual results:
The accessed file is corrupt

Expected results:
The accessed file is downloaded as is and can be used


Additional info:
It does not happen with Gnome's nautilus.
The temporary file created from the download in /var/tmp/kdecache-<username>/krun/... is larger than the original. When examining it, one can find, that parts repeat inside.
The problem has to do with the queued handling of read requests in kioslave/sftp/kio_sftp.cpp . In sftpProtocol::GetRequest::readChunks i see, that if not enough bytes have been read, the request is re-issued, what might not be the appropriate action. Particularly what i see happening: First 32768 bytes are read. 61440 had been requested. So the request is re-issued. Next 28672 bytes are read. Then 32768 are read, which start with the same stuff like the 28672 bytes read before. So something is quite badly wrong here. I haven't yet fully understood how to fix this. When i find it i'll post, but i don't have arbitrary time and i guess the maintainer is more familiar with the code.

Thank you.

Comment 1 Rex Dieter 2014-12-31 16:27:13 UTC
Thanks for the analysis.

ideally, it would be best if you filed this upstream @
https://bugs.kde.org/enter_bug.cgi?product=kio&format=guided

against component sftp

Comment 2 Albert Flügel 2015-01-01 15:57:14 UTC
Note: I think the assumtion in sftpProtocol::GetRequest::readChunks, that it is an error, when sftp_async_read returns less bytes than requested, is not appropriate. Especially when reading asynchronously and e.g. over a not so fast connection (what is the case here), i'd consider it normal, that i have to issue several read requests

Comment 3 Rex Dieter 2015-01-01 23:05:21 UTC
thanks for the upstream report, will continue tracking there.

Comment 4 Rex Dieter 2015-01-11 13:26:33 UTC
Pulling in upstream fix...

Comment 5 Fedora Update System 2015-01-11 14:14:02 UTC
kde-runtime-4.14.3-3.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/kde-runtime-4.14.3-3.fc21

Comment 6 Fedora Update System 2015-01-11 14:14:48 UTC
kde-runtime-4.14.3-3.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/kde-runtime-4.14.3-3.fc20

Comment 7 Fedora Update System 2015-01-12 23:59:21 UTC
Package kde-runtime-4.14.3-3.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing kde-runtime-4.14.3-3.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-0569/kde-runtime-4.14.3-3.fc21
then log in and leave karma (feedback).

Comment 8 Fedora Update System 2015-01-14 23:59:01 UTC
kde-runtime-4.14.3-3.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2015-01-26 02:31:29 UTC
kde-runtime-4.14.3-3.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.